TRENDGCD - Trending GCD

no tags 

Problem statement is simple. Given A and B you need to calculate S(A,B) .

sigma(a=1 to A)sigma(b=1 to B) (a*b*f(gcd(a,b)))

Here, f(n)=n, if n is square free otherwise 0. Also f(1)=1.

Input

The first line contains one integer T - denoting the number of test cases.

T lines follow each containing two integers A,B.

Output

For each testcase output the value of S(A,B) mod 1000000007 in a single line.

Constraints

  • T <= 1000
  • 1 <= A,B <= 1000000

Example

Input:
3
42 18
35 1
20 25

Output:
306395
630
128819

hide comments
rainy jain : 2016-06-03 02:53:21

@Adarsh what is the expected complexity?

jame_: 2016-04-18 23:26:05

getting TLE any suggestion


Added by:Adarsh kumar
Date:2016-01-04
Time limit:0.150s-0.389s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU JS-MONKEY