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.

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

hide comments
2014-06-08 12:42:39 Venkata Amaresh
hello...it says wrong answer...i ran the program in ideone...it gave the correct answer....pl tell me what to do??
2014-06-08 05:50:29 Chaitanya Kiran Gubbala
Limit on the output bytes that the program allowed to print.
how to overcome?
2014-06-01 10:29:45 Karan Mali
i cant see the question.. pdf is blank.. how can i get it?
2014-06-01 09:31:22 Shivam Bhardwaj
i cant see d problem.. :[ pliz help
2014-05-31 13:27:21 Jyothsna Pal
My code written in Java runs fine in eclipse but it shows compilation error here. how do i go ahead?
2014-05-30 16:36:34 somil garg
time limit exceed
2014-05-29 06:33:54 Jayesh Lata
@Riya ..the input/output are from/to the standard input/output file...given the large values...use long int, should work if you are confident about the algo
2014-05-28 15:34:34 Riya Midha
in what form should we take input and give output??
2014-05-28 15:33:50 Riya Midha
my code is working correctly and giving proper solutions but here it is saying wrong answer ....is it because of the input and output method????
2014-05-28 07:28:24 Venkatesh S
Guess there is some issue with the Java Compiler. Code runs fine in eclipse. but it shows compilation error here.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.