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
2016-06-01 10:10:48
time limit exceeded, no idea why????
2016-06-01 01:20:38
those who are getting runtime error in python don't do it with files
2016-05-26 15:15:46
IdeOne says Osec but SPOJ says time exceeded
2016-05-26 12:29:11
My code was compiled and i got the right answer. But When I upload it into spoj it says compilation error.
2016-05-22 22:07:45
I'm using Sieve of Eratosthenes algorithm but I keep getting TLE! no matter what algorithm I use.

Last edit: 2022-06-19 12:16:07
2016-05-21 19:52:09
i am getting TLE tell me how to overcome this problem
2016-05-20 19:17:50
Search Sieve of Eratosthenes
2016-05-20 15:55:03
Why is my code showing wrong answer? It's working quite well in ideone. There are no test cases. We can't see the output. Nor can we see the optimized solution. Can anybody help, please?
2016-05-17 03:29:12
f****** easy
2016-05-09 18:49:04 ajit
I have issues compiling the code in SPOJ. It works in eclipse though.
I posted a question in stackoverflow. Could someone help me solve this. Thanks.


Last edit: 2022-06-19 12:16:23
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.