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
div_25:
20180812 20:17:00
Guys check for 1. I spent a ton of time only to find 1 was showing up as prime. And use sqrt(). 

magnus_007:
20180806 12:15:23
use normal method no need to use sieve or segmented 

badtmeez:
20180803 06:58:42
Use segmented sieve....... 

chirag74:
20180802 23:03:52
LOL guys i was literally scratching my head trying to apply sieve of erastothenes to find all primes upto billion and some other algorithm. Trust me it wont work cus they dont even test it upto a billion. Just check if the number is a prime each time. LOLOLOL. Man i hate this question. I really wonder why is it in classical? 

paresh121:
20180801 16:34:14
how to reduce time to print a number?


division_7:
20180801 16:03:48
This Question is amazing as if it has no answer to it i tried using python,c and cpp even that sieve algo none works only TLE error is there my god. 

priyankamani:
20180801 15:28:06
why you are saying the answer is wrong .plz give the test cases 

suyashky:
20180731 15:35:14
Do not forget to check 1! 

vishalroybitp:
20180729 18:18:25
What the heck.Tried running sqrt(),n,n/2.and guess what still TLE.


danfrown:
20180721 18:36:29
Well god help me. I ran the loop till sqrt(n) till n/2 till n. And guess what? I still get time limit exceeded. I'm using C. Help me... Anyone..?

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