Farey Sequence Length

Compute 1 plus the sum of Euler totient values up to N for each of up to 10000 data sets.

Medium4Number theoryPrefix sumMathNo attempts yetTime limit1sMemory limit256 MB

Problem

For a positive integer NN, collect every fraction a/ba/b with 0abN0 \le a \le b \le N and gcd(a,b)=1\gcd(a, b) = 1, then list them from smallest to largest. That list is the Farey sequence of order NN.

For example, the Farey sequence of order 6 is

0/1, 1/6, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 5/6, 1/10/1,\ 1/6,\ 1/5,\ 1/4,\ 1/3,\ 2/5,\ 1/2,\ 3/5,\ 2/3,\ 3/4,\ 4/5,\ 5/6,\ 1/1

Write a program that computes the length of the Farey sequence of order NN, that is, how many fractions it holds.

Input

The first line contains the number of data sets PP (1P100001 \le P \le 10000). The data sets are independent of each other and are all processed the same way.

Each of the next PP lines holds one data set: the data set number KK (1K100001 \le K \le 10000) and the order NN (2N100002 \le N \le 10000) of the Farey sequence whose length is wanted, separated by one space.

Output

Print one line per data set. Each line holds the data set number KK, one space, and the length of the Farey sequence of order NN as a decimal integer.