A plot of land can be described by $M x N$ dots such that horizontal and vertical distance between any two dots is 10m.
Mr. Wolf would like to build a house in the land such that all four sides of the house are equal. Help Mr. Wolf to find the total number of unique positions where houses can be built. Two positions are different if and only if their sets of four dots are different.
-----Input:-----
The first line of the input gives the number of test cases, $T$. $T$ lines follow. Each line has two integers $M$ and $N$: the number of dots in each row and column of the plot, respectively.
-----Output:-----
For each test case, output one single integer containing the total number of different positions where the house can be built.
-----Constraints-----
- $1 \leq T \leq 100$
- $2 \leq M \leq 10^9$
- $2 \leq N \leq 10^9$
-----Sample Input:-----
4
2 4
3 4
4 4
1000 500  
-----Sample Output:-----
3
10
20
624937395  
-----EXPLANATION:-----
Map 1
Map 2
Map 3
# cook your dish here
mod = 1000000007
t = int(input())
for _ in range(t):
    m, n = list(map(int, input().split()))
    x = min(m, n)
    f1 = m * n % mod
    s1 = x * (x - 1) // 2 % mod
    f2 = (m + n) % mod
    s2 = x * (x - 1) * (2*x - 1) // 6 % mod
    s3 = s1 * s1 % mod
    ans = (f1 * s1 % mod - f2 * s2 % mod + s3) % mod
    print(ans)



# cook your dish here
mod = 1000000007
t = int(input())
for _ in range(t):
    m, n = list(map(int, input().split()))
    x = min(m, n)
    f1 = m * n % mod
    s1 = x * (x - 1) // 2 % mod
    f2 = (m + n) % mod
    s2 = x * (x - 1) * (2*x - 1) // 6 % mod
    s3 = s1 * s1 % mod
    ans = (f1 * s1 % mod - f2 * s2 % mod + s3) % mod
    print(ans)


