# [BZOJ 2693]jzptab 莫比乌斯反演

$$ans=\sum_{i=1}^n \sum_{j=1}^m lcm(i,j)$$

$$=\sum_{i=1}^n \sum_{j=1}^m \frac{i*j}{gcd(i,j)}$$

$$ans=\sum_{d=1}^n d \sum_{i=1}^{\lfloor \frac{n}{d} \rfloor} \sum_{j=1}^{\lfloor \frac{m}{d} \rfloor} [gcd(i,j)==1]\frac{i*d*j*d}{d}$$

$$ans=\sum_{d=1}^n d \sum_{t=1}^{\lfloor \frac{n}{d} \rfloor} \mu(t) \sum_{i=1}^{\lfloor \frac{n}{td} \rfloor} \sum_{j=1}^{\lfloor \frac{m}{td} \rfloor} i*t*j*t$$

$$=\sum_{d=1}^n d \sum_{t=1}^{\lfloor \frac{n}{d} \rfloor} \mu(t) t^2 \sum_{i=1}^{\lfloor \frac{n}{td} \rfloor}i \sum_{j=1}^{\lfloor \frac{m}{td} \rfloor}j$$

$$ans=\sum_{d=1}^n d \sum_{t=1}^{\lfloor \frac{n}{d} \rfloor} \mu(t) t^2 sum({\lfloor \frac{n}{td} \rfloor},{\lfloor \frac{m}{td} \rfloor})$$

$$ans=\sum_{D=1}^{min(n,m)}sum(\lfloor \frac{n}{D}\rfloor,\lfloor\frac{m}{D}\rfloor)\sum_{i|D}\mu(i)*i^2*\frac Di$$

$$g(x)=\sum_{i|D}\mu(i)*i^2*\frac Di$$

$g(p)=\mu(1)*p+\mu(p)*p*p=p-p^2$

$$g(i*p)=\sum_{d|i}\mu(d)*d*i*p+\sum_{d*p|i*p}\mu(d*p)*d*p*i*p$$

$$=p*g(i)-p^2*g(i)$$

$$=g(i)*g(p)$$

$i=i_1*p^y$

$$g(i*p)=\sum_{d|i}\mu(d)*d*i*p$$

$$=g(i)*p$$

#include <cstdio>
#include <cstring>
using namespace std;
#define N 10000010
#define LL long long
#define mod 100000009
#define pos(i,a,b) for(LL i=(a);i<=(b);i++)
char B[1<<15],*S=B,*T=B;
{
int x=0;register char c=getc;
while(c<'0'||c>'9')c=getc;
while(c>='0'&&c<='9')x=10*x+(c^48),c=getc;
return x;
}//快读
int prime[N/10],notprime[N];
LL g[N];
inline int min(int a,int b){return a<b?a:b;}
inline LL gsum(LL a,LL b){
return ( (a*(a+1)>>1)%mod )*( (b*(b+1)>>1)%mod )%mod;
}
LL ans;
int t,n,m;
int main()
{
g[1]=1;
pos(i,2,N-10){
if(!notprime[i])
prime[++prime[0]]=i,g[i]=(i-(LL)i*i)%mod;
for(int j=1;j<=prime[0]&&(i*prime[j])<=N-10;++j){
notprime[i*prime[j]]=1;
if(i%prime[j]==0){g[i*prime[j]]=g[i]*prime[j]%mod;break;}
g[i*prime[j]]=g[i]*g[prime[j]]%mod;
}
}
pos(i,1,N-10) g[i]=(g[i-1]+g[i])%mod;
while(t--){