#P5348. 密码解锁

密码解锁

Description

One day, WD found a very strange combination lock. He remembered that before CX asked him to unlock it, CX told him some numbers. Unfortunately, since WD is really bad at this, he forgot what those numbers were. He only remembers that after numbering them from 11 to nn, for any positive integer d(1dn)d(1\le d\le n), the sum of all numbers whose indices are multiples of dd is exactly μ(d)\mu(d) (that is, the Möbius function value of dd).

Now, to open this lock, he must know the number at position mm. Since he cannot do anything, he asks you for help.

Input Format

The first line contains an integer TT, indicating the number of test cases. The next TT lines each contain two integers n,mn,m.

Output Format

Output TT lines. Each line contains one integer, representing the value of the mm-th number. It can be proven that the answer is unique.

2
5 1
5 2
4
-1

Hint

subtask1(21pts): n106, T5subtask1(21pts):~n\le 10^6,~T\le 5.

subtask2(34pts): n107, T10subtask2(34pts):~n\le 10^7,~T\le 10.

$subtask3(45pts):~n\le 10^{18},~m\le 10^9,~\frac{n}{m}\le 10^9,~T\le 20$.

For all testdata, mnm\le n.

For sample 1, the sequence that satisfies the requirement is 4 -1 -1 0 -1.

Translated by ChatGPT 5