There is an ant named Alice. Alice likes going hiking very much. Today, she wants to climb a cuboid. The length of cuboid's longest edge is n, and the other edges are all positive integers. Alice's starting point is a vertex of this cuboid, and she wants to arrive at the opposite vertex. The opposite vertex means the vertex which has no common planes or edges with the starting point. Just like the picture below:

Input
The first line of input contains an integer T(T ≤ 100) . T is the number of the cases. In the following T lines, there are a positive integer n(1≤n≤1014) in each line. n is the longest edge of the cuboid.
Output
For each test case, output the sum of L2 for every possible cuboid in a line. L is the length of shortest path of a cuboid. It may be very large, so you must output the answer modulo 1000000007.
Sample Input
2 3 4
Sample Output
160 440
Hint
(3,2,1) and (3,1,2) are regrad as the same cuboids.
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define MAXN 205
#define M 100005
#define MOD 1000000007
int x,y,rev;
int n2,n6;
void extend_Euclid(int a,int b){
if(b==0) {
x=1;
y=0;
return ;
}
extend_Euclid(b,a%b);
int t=x;
x=y;
y=t-a/b*y;
}
void init(){
extend_Euclid(2,MOD);
n2=(x%MOD+MOD)%MOD;
extend_Euclid(6,MOD);
n6=(x%MOD+MOD)%MOD;
}
int main()
{
init();
int T;
scanf("%d",&T);
while(T--){
ll n,ans=0;
scanf("%llu",&n);
ll t = ((((n%MOD)*((n+1)%MOD))%MOD)*n2)%MOD;
ans = (ans+(t*t)%MOD)%MOD;
t = (((((((n%MOD)*((n+1)%MOD))%MOD)*((2*n+1)%MOD))%MOD)%MOD)*n6);
ans = (ans + ((t%MOD)*((n+2)%MOD))%MOD) % MOD;
ans = (ans + ((((((((n%MOD)*(n%MOD))%MOD)*((1+n)%MOD))%MOD)*(n%MOD))%MOD)*n2)%MOD)%MOD;
printf("%llu\n", ans);
}
return 0;
}
Author: MU, Tongzhou