using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ List L = new List(); int[] P = new int[1500000]; for(int i=2;i<1500000;i++){ if(P[i] == 0){ L.Add(i); for(int j=i+i;j<1500000;j += i) P[j] = 1; } } long mod = (long) 1e9+7; long[] ans = new long[Q]; for(int q=0;q= mod) ret0 %= mod; ret0 *= pm; if(ret0 >= mod) ret0 %= mod; ret0 += mod - (i+a+1) ; if(ret0 >= mod) ret0 -= mod; ret0 *= pm; if(ret0 >= mod) ret0 %= mod; ret *= ret0; if(ret >= mod) ret %= mod; } ans[q] = ret; } Console.WriteLine(String.Join("\n",ans)); } static long mod = (long) 1e9+7; static long ModInv(long x){ long a=0,b=0,c=0; if(x==0)return 0; ExtGCD(x,mod,ref a,ref b,ref c); if(c!=1)return 0; return (a+mod)%mod; } static long ModPow(long x,long k){ if(k == 0)return 1; if(x == 0)return 0; long ret = 1; long xx = x; while(k>0){ if((k&1)==1){ret *= xx; if(ret >= mod) ret %= mod;} xx *= xx; if(xx >= mod) xx %= mod; k>>=1; } return ret; } static void ExtGCD(long x,long y,ref long a,ref long b,ref long c){ long r0=x;long r1=y; long a0=1;long a1=0; long b0=0;long b1=1; long q1,r2,a2,b2; while(r1>0){ q1=r0/r1; r2=r0%r1; a2=a0-q1*a1; b2=b0-q1*b1; r0=r1;r1=r2; a0=a1;a1=a2; b0=b1;b1=b2; } c=r0; a=a0; b=b0; } int Q; int[] M,A; public Sol(){ Q = ri(); M = new int[Q]; A = new int[Q]; for(int i=0;iint.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }