PRIME1 - Prime Generator


Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers!

Input

The input begins with the number t of test cases in a single line (t<=10). In each of the next t lines there are two numbers m and n (1 <= m <= n <= 1000000000, n-m<=100000) separated by a space.

Output

For every test case print all prime numbers p such that m <= p <= n, one number per line, test cases separated by an empty line.

Example

Input:
2
1 10
3 5

Output:
2
3
5
7

3
5
Warning: large Input/Output data, be careful with certain languages (though most should be OK if the algorithm is well designed)

Information

After cluster change, please consider PRINT as a more challenging problem.

hide comments
Aashish Rathi: 2014-06-15 21:37:11

my code runs fine locally and even on ideone.com but gives SIGBORT thingy error.

Saumil Joshi: 2014-06-13 00:09:47

my code runs perfectly on gcc(linux) and also on ideone with the inputs but here i ger a runtime error(a segmentation fault)

Shruti Jalan : 2014-06-12 10:39:07

finally..huh..beware of tle s

Nitin Khulbe: 2014-06-10 10:00:21

my code runs corr i get wrong answer plz..help me out..ect in ideone but here

studmax: 2014-06-09 16:17:54

working fine locally but giving a compilation error here Can someone pls help me out

venkata meghasyam: 2014-06-09 13:06:07

we can not solve this problem using convenational method we have to use http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

karan: 2014-06-08 14:35:14

how do we get the question in form of pdf ?

bv45: 2014-06-08 14:19:15

i tried so many test cases but it still give TIME LIMIT EXCEEDED. How can i overcome this issue ? plzz help!!!!

Venkata Amaresh: 2014-06-08 12:42:39

hello...it says wrong answer...i ran the program in ideone...it gave the correct answer....pl tell me what to do??

Chaitanya Kiran Gubbala: 2014-06-08 05:50:29

Limit on the output bytes that the program allowed to print.
how to overcome?


Added by:Adam Dzedzej
Date:2004-05-01
Time limit:6s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS PERL6