CSES - Totient sums
  • Time limit: 2.00 s
  • Memory limit: 512 MB

An Euler's totient function is defined as φ(n)\varphi(n) is the number of ii, 1in1 \le i \le n, such that ii and nn are co-prime.
Your task is, given aa and bb, to output φ(a)+φ(a+1)++φ(b)\varphi(a) + \varphi(a+1) + \ldots + \varphi(b).

Input:

First line of input contains TT, number of testcases, T105T \le 10^5.
In each of next TT lines there is a pair of integers a,ba,b, 1ab1071 \le a \le b \le 10^7.

Output:

For each testcase, output a single integer, the answer to the problem.

Example:

3
6 6 
7 10
10 1000
2
20
304164

Explanation:
φ(6)=2\varphi(6) = 2, and φ(7)=6\varphi(7) = 6, φ(8)=4\varphi(8) = 4, φ(9)=6\varphi(9) = 6 and φ(10)=4\varphi(10) = 4.