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
ankitkumarx: 2022-01-10 15:49:21

My code is taking 0.01 sec to execute, but the website is leaving a message of 'time limit exceed'.

orno: 2021-11-25 17:56:55

Does any of you have tricky testcases ?
I don't understand why my code gives WA

amirthtr: 2021-11-03 19:00:32

I have time error ((:

amirthtr: 2021-11-03 17:02:57

time limit exceeded= program is Heavy and overly complex solution

Last edit: 2021-11-03 18:21:42
niezlypajacpl: 2021-11-01 19:25:03

co to jest runtime error (NZEC)

cameron_knows: 2021-10-20 20:20:02

I'm getting correct output. Judge still not accepting?

raman_95: 2021-09-29 13:28:54

ideone is also showing success and with timelimits , but solution is Status bar shows Time limit exceeded . Anyone else facing the same issue

belrol: 2021-09-23 22:30:29

I'm not sure how the judging system works here. Is it accepting only a predetermined solution, for example here the segmented sieve(which I only now looked up what is), or it accepts a few type of solutions? Because my code works perfectly and gives the exact required output, but I get "wrong answer" all the time for this problem.

novinsky1: 2021-08-16 15:02:16

<snip>
on spoj compilation error, but compilation has no errors

[NG]: Your main() is defined as int but doesn't return anything.

Last edit: 2021-08-16 22:43:35
nullptrchef101: 2021-07-29 10:29:00

Getting TLE, how to deal with it?


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