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
2013-12-22 08:45:34 Rohan Jitendra Pota
[code removed]
its showing time limit exceeded.what to do ?plplzzzzzhelp!!

(Mitch) ---
"1. Don't post any source code here."

You may try the forum for help with such things.

Edit: I see that you already did, but you either didn't read TripleM's post "Read this before posting!" or you didn't take it to heart. So you might want to go and do that. But anyway your problem is simple enough, I'll reply to that thread you started.
---

Last edit: 2013-12-22 09:32:30
2013-12-20 09:46:58 ritu
tle :( u have told reason of tle in previous comment but i didn't get it .. pls explain it
2013-12-17 14:31:20 Pranav Zarekar
TLE.. :(
What care should be taken guys???
2013-12-15 10:18:10 Mitch Schwartz
@Rohan: I deleted your latest comment for obvious reasons. conio.h is not part of standard C, so there's nothing unusual at all about that error message. http://en.wikipedia.org/wiki/Conio.h
2013-12-15 07:00:55 Rohan Jitendra Pota
conio.h: No such file or directory
what the hell???
2013-12-12 16:57:50 p@dfoot
my program is running perfectly on my pc but here they have not given the input correctly
2013-12-10 04:20:55 Viraj
How do we see what tests SPOJ is running on our code?
2013-12-05 11:10:07 Washington
lol. The author himself could not solve the problem.
2013-11-30 17:08:40 Dhruv Mullick
Getting a SIGSEGV error in this
<snip>.. Is this because of the large array?

Last edit: 2022-06-19 12:32:06
2013-11-26 13:08:14 luke manuel daely
for those who complain about code work very fast in ideone but get tle in spoj should try to input the maximum number of case that contain maximum number of n-m.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.