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
doanva: 2015-10-13 10:17:06

Use this checking method would be accepted
bool isPrime(int i) {
...
}

Last edit: 2015-10-13 10:17:51
Abhimanyu Srivastava: 2015-10-12 18:24:46

sieve of erasthonesis doesn't work

saikiran_skr: 2015-10-12 13:03:22

time limit exceeded!! why?

Dan Chrostowski: 2015-10-12 06:31:18

runtime error in perl. Would be nice to know what the friggin error is. I'm done wasting my time here.

kiner_shah: 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
samnik: 2015-10-05 12:03:33

my code is showing tle error please rectify the code

ashu05: 2015-10-04 09:49:35

showing runtime error... yet it works well on codeblocks ===> need help

ghostman13: 2015-10-03 19:03:21

my solution works fine but it's giving wrong answer

hormonas_7: 2015-10-02 10:51:09

My solution gets: runtime error but it works fine here (i think)...

skroxx: 2015-10-01 20:23:15

My code gives runtime error. But for most of the test cases it runs fine


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