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.

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

hide comments
2014-06-17 10:15:46 785227
I am using int, My code gets acc with cout but shows WA with printf ?? Can anyone explain why this problem occurs ?

--ans(Francky)--> I suggest you to put here (only) your printf command with arguments, you perhaps forgot to add a new line.

Last edit: 2014-06-17 10:52:16
2014-06-17 06:23:12 Roniit Bhimrajka
I am using Java.It shows TLE. Please help.Code at <snip>

Last edit: 2022-06-19 12:36:20
2014-06-15 21:37:11 Aashish Rathi
my code runs fine locally and even on ideone.com but gives SIGBORT thingy error.
2014-06-13 00:09:47 Saumil Joshi
my code runs perfectly on gcc(linux) and also on ideone with the inputs but here i ger a runtime error(a segmentation fault)
2014-06-12 10:39:07 Shruti Jalan
finally..huh..beware of tle s
2014-06-10 10:00:21 Nitin Khulbe
my code runs corr i get wrong answer plz..help me out..ect in ideone but here
2014-06-09 16:17:54 studmax
working fine locally but giving a compilation error here Can someone pls help me out
2014-06-09 13:06:07 venkata meghasyam
we can not solve this problem using convenational method we have to use http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
2014-06-08 14:35:14 karan
how do we get the question in form of pdf ?
2014-06-08 14:19:15 bv45
i tried so many test cases but it still give TIME LIMIT EXCEEDED. How can i overcome this issue ? plzz help!!!!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.