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
2015-10-12 06:31:18 Dan Chrostowski
runtime error in perl. Would be nice to know what the friggin error is. I'm done wasting my time here.
2015-10-05 18:54:23
runtime error! God knows why! Algorithm is perfect! Does c++ have any range constraints?
please check my submission! 15297588

Last edit: 2015-10-05 19:12:40
2015-10-05 12:03:33
my code is showing tle error please rectify the code
2015-10-04 09:49:35
showing runtime error... yet it works well on codeblocks ===> need help
2015-10-03 19:03:21
my solution works fine but it's giving wrong answer
2015-10-02 10:51:09
My solution gets: runtime error but it works fine here (i think)...
2015-10-01 20:23:15
My code gives runtime error. But for most of the test cases it runs fine
2015-10-01 17:53:01
Code ststus is "success" in idone.com but SPOJ environment showing error. why? Any suggestion?
2015-09-30 15:42:54
time limit exceeded!!
any suggestions?
2015-09-30 08:56:55
time limit exceeded help
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.