## BSSPC '21 J5 - James and the Euclid Test

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Java 2.0s
Python 2.0s
Memory limit: 256M

Author:
Problem types

With university applications around the corner, James decides to apply for the University of Watermoo. However, in order to do that, he needs to get "gud" and do well on the Euclid Math contest hosted by said university. Thus he decides to not repeat the same mistake this year and actually study for the Euclid contest. In particular, he is currently studying primes. He knows the math but he wants to check his work. So he hires you, a slave friend to create a program that would answer his questions.

His questions are in the following form:

• Let be defined as the smallest prime greater than or equal to . If is prime, then . Given two positive integers and , James wants to know . He also wants to know the sum of all primes from to inclusive.

Since James really wants to test his skills, he will ask your program times.

Note: Fast I/O is recommended for this problem. For this problem, Python users are recommended to use PyPy over CPython.

#### Input Specification

The first line will contain one integer , denoting the number of questions your program has to answer.

The next lines will contain the two integers .

#### Output Specification

Output lines. On each line, output two space-separated integers. and the sum of all primes from to inclusive.

#### Sample Input

4
1 5
2 6
11 1
14 4

#### Sample Output

11 28
13 41
11 11
29 88

#### Explanation for Sample Output

For the first question, . The sum of all the primes in is .

For the second question, . The sum of all the primes in is .

For the third question, . The sum of all the primes in is .

For the last question, . The sum of all the primes in is .