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
code_do: 2014-06-27 08:06:51

@Adam I am getting SIGABRT error in my code,but its running fine on ideone.please help me with this
<snip>

Last edit: 2022-06-19 12:36:49
Poonam Adhav: 2014-06-26 22:04:41

my code runs fine on ideone.com but gives time limit exceeds....please help

kotti satish: 2014-06-25 16:24:13

i've tried many test cases.....still time limit exceeds

Yosra: 2014-06-25 13:35:47

I got compilation error. Can any one help me to catch what's wrong?

Archit Jain: 2014-06-23 10:12:15

good one...!!

Adarsh K: 2014-06-21 19:22:13

Can anyone give the capacity of given system?? The no of operations it can perform in one second?? Also pls give me the maximum size of an array supported by the compiler...

Last edit: 2014-06-21 19:24:26
kishon: 2014-06-20 20:13:02

I too keep getting runtime error (SIGSEGV) :-(

classified_01: 2014-06-17 19:24:20

Optimized sieve not helping either.....runtime error (SIGSEGV) .
How can i overcome the error ?

785227: 2014-06-17 10:15:46

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
Roniit Bhimrajka: 2014-06-17 06:23:12

I am using Java.It shows TLE. Please help.Code at <snip>

Last edit: 2022-06-19 12:36:20

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