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
Sayed Jaffar: 2013-12-23 16:38:47

I have one question..
"t" from where I can get it ??
can I put it equal 10 or what ??

Rohan Jitendra Pota: 2013-12-22 08:45:34

[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
ritu: 2013-12-20 09:46:58

tle :( u have told reason of tle in previous comment but i didn't get it .. pls explain it

Pranav Zarekar: 2013-12-17 14:31:20

TLE.. :(
What care should be taken guys???

Mitch Schwartz: 2013-12-15 10:18:10

@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

Rohan Jitendra Pota: 2013-12-15 07:00:55

conio.h: No such file or directory
what the hell???

p@dfoot: 2013-12-12 16:57:50

my program is running perfectly on my pc but here they have not given the input correctly

Viraj: 2013-12-10 04:20:55

How do we see what tests SPOJ is running on our code?

Washington: 2013-12-05 11:10:07

lol. The author himself could not solve the problem.

Dhruv Mullick: 2013-11-30 17:08:40

Getting a SIGSEGV error in this
<snip>.. Is this because of the large array?

Last edit: 2022-06-19 12:32:06

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