Sexy Primes
Easy Accuracy: 12.49% Submissions: 2810 Points: 2

Sexy primes are prime numbers that differ from each other by six. For example, the numbers 5 and 11 are both sexy primes, because they differ by 6. Given a range of the form [L, R]. The task is to print all the sexy prime pairs in the range in increasing order.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case two integers L and R.

Output:
For each test case, print all the sexy prime pairs in the range in increasing order in new line. If no sexy prime pair is there print "-1".

Constraints:
1 <= T <= 100
1 <= L <= R <= 107

Example:
Input:

2
11 19
6 59
Output:

11 17 13 19
7 13 11 17 13 19 17 23 23 29 31 37 37 43 41 47 47 53 53 59

Explanation:

Input : L = 6, R = 59
Output : (7, 13) (11, 17) (13, 19) 
(17, 23) (23, 29) (31, 37) (37, 43) 
(41, 47) (47, 53) (53, 59)

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.