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, nm<=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 5Warning: 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
ptrsn311:
20180121 01:19:18
@hsakiv220290, a prime has exactly two divisors, the number 1 only has 1 (itself) 

shubham_chopra:
20180119 20:29:38
use segmented sieve, normal sieve will give TLE 

suchismitadhal:
20180119 15:41:20
for TLE no need of Sieve algo., filter the numbers against 2 to the square root of the number. Accepted. 

hsakiv220290:
20180117 12:17:05
@manahax, 1 is divisible by 1 and itself. SO it is prime 

youngchaeseo:
20180117 08:21:48
I tested the problem and worked, but the real problem question doesn't work. hmmm 

manahax:
20180116 22:08:24
@hsakiv220290, 1 is not prime


nayan_ansh:
20180114 07:53:39
I am using java and my code work in my computer(outside this website) but it is showing error when I submit it. 

vikramvarun:
20180111 13:51:24
Solved in java but getting WA in R. ID 20965189 and 20965178 (tried both with and without empty line at end of last test case). Sample test case prints expected output and I can't find any problem. Please help. 

hsakiv220290:
20180110 08:35:52
In example, 1st test case ,1 is a prime number. 

vuminhthanh01:
20180103 15:34:27

Added by:  Adam Dzedzej 
Date:  20040501 
Time limit:  6s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 