The Prime Twins
Submissions: 555   Accuracy:

41.26%

  Difficulty: Easy   Marks: 2

Given two positive numbers L and R (L < R), find out the smallest twins in the range [L , R].Two numbers are twins if they are prime numbers and there difference is 2.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains two positve integers L and R (L < R), denoting the range [L < R].

Output:
Print out the smallest twins in the given range. If no such twins exist, then print -1.

Constraints:
1 <= T <= 200
0 <= L <= 500
0 <   R <= 1000

Examples: 
Input:
4
10 100
20 50
850 900
15 18

Output:
11 13
29 31
857 859
-1

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Rohan Malhotra


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.