#nt904. gcd之和

gcd之和

Sum of GCDs

Problem Description

TT queries. Each query gives two numbers n,mn, m; compute ∑i=1n∑j=1m(i,j)\sum_{i=1}^n \sum_{j=1}^m (i, j), where (i,j)(i, j) denotes gcd⁡(i,j)\gcd(i, j).

Input Format

The first line contains an integer TT.

The next TT lines each contain two integers n,mn, m.

Output Format

A total of TT lines, each containing one number: the answer.

Sample Input

3
100 200
1000 2000
1000000 2000000

Sample Output

63542
9067212
17457854316166

Constraints

For all data, 1≤T≤10001\leq T\leq 1000 and 1≤n,m≤1071\leq n, m \leq 10^7 are guaranteed.