Hillan and the girl

Time Limit: 6000ms
Memory Limit: 524288KB
This problem will be judged on HDU. Original ID: 5663
64-bit integer IO format: %I64d      Java class name: Main

Description

“WTF! While everyone has his girl(gay) friend, I only have my keyboard!” Tired of watching others' affair, Hillan burst into scream, which made him decide not to hold it back.
“All right, I am giving you a question. If you answer correctly, I will be your girl friend.” After listening to Hillan, Girl replied, “What is the value of $\sum_{i=1}^n\sum_{j=1}^mf\left(i,j\right)$, where $f\left(i,j\right)=0$ if $\gcd\left(i,j\right)$ is a square number and $f\left(i,j\right)=1$ if $\gcd\left(i,j\right)$ is not a square number($\gcd\left(i,j\right)$ means the greatest common divisor of x and y)?”
But Hillan didn't have enough Intelligence Quotient to give the right answer. So he turn to you for help.

Input

The first line contains an integer $T\left(1\leq T\leq10,000\right)$——The number of the test cases.
For each test case, the only line contains two integers $n,m\left(1\leq n,m\leq10,000,000\right)$ with a white space separated.

Output

For each test case, the only line contains a integer that is the answer.

Sample Input

2
1 2333333
10 10

Sample Output

0
33

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .