Problem title
Difficulty
Avg time to solve

Beautiful String
Easy
18 mins
Set Matrix Zeros
Easy
30 mins
Yogesh And Primes
Moderate
20 mins
First Missing Positive
Moderate
18 mins
Swap Two Numbers
Easy
10 mins
Longest Univalue Path
Moderate
10 mins
Find Unique
Easy
--
Valid Sudoku
Moderate
40 mins
Reverse Nodes in k-Group
Hard
56 mins
Sum Of Max And Min
Easy
10 mins
308

# Yogesh And Primes

Difficulty: MEDIUM
Avg. time to solve
20 min

Problem Statement

#### Note: A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

##### Input format :
``````The first line of input contains one positive integer Q.
The following Q lines contains three spaced-separated integers A, B and K.
``````
##### Output format :
``````For each query, print the answer in a new line, if it exists, else print −1.
``````
##### Constraints:
``````1≤Q≤100,000
1≤A≤B≤1,000,000
1≤K≤1,000,000
A≤P≤B
``````
##### Sample Input :
``````5
2 5 1
2 5 2
4 12 2
3 17 7
5 5 1
``````
##### Sample Output :
``````2
3
7
-1
5
``````
Console