#C10551. Prime Numbers in Multiple Ranges

    ID: 39769 Type: Default 1000ms 256MiB

Prime Numbers in Multiple Ranges

Prime Numbers in Multiple Ranges

You are given several ranges in the form of pairs of integers a and b. For each range, you need to find all prime numbers in the interval \([a, b]\) (both ends inclusive). A prime number is defined as a natural number greater than 1 that has no divisors other than 1 and itself, i.e. \(n > 1\) and if \(d|n\) then \(d = 1\) or \(d = n\).

Your task is to process multiple test cases. For each test case, print the prime numbers in ascending order separated by a single space. If there are no prime numbers in the range, output an empty line.

Input Format: The first line contains an integer T denoting the number of test cases. The following T lines each contain two integers separated by a space, representing the values of a and b.

Output Format: For each test case, print a line containing the prime numbers separated by a space. Print an empty line if there are no prime numbers in the given range.

inputFormat

The input begins with a single integer T indicating the number of test cases. Each of the next T lines contains two space-separated integers a and b which define the inclusive range \([a, b]\) within which you are to find prime numbers.

outputFormat

For each test case, output a single line containing all the prime numbers in the range \([a, b]\) sorted in ascending order and separated by a single space. If no prime numbers exist in the range, output an empty line.

## sample
2
10 20
4 6
11 13 17 19

5

</p>