1 #include<cstdio>
2 #include<cstring>
3 #include<iostream>
4 using namespace std;
5
6 typedef long long ll;
7 const int N = 1e7+10;
8 const int MOD = 20101009;
9
10 ll mu[N],su[N],sz,np[N];
11 int n,m,mx;
12
13 void get_mu()
14 {
15 int i,j;
16 mu[1]=1;
17 for(i=2;i<=mx;i++) {
18 if(!np[i])
19 su[++sz]=i,mu[i]=-1;
20 for(j=1;j<=sz&&i*su[j]<=mx;j++) {
21 np[i*su[j]]=1;
22 if(i%su[j]==0)
23 mu[i*su[j]]=0;
24 else
25 mu[i*su[j]]=-mu[i];
26 }
27 }
28 for(i=1;i<=mx;i++)
29 mu[i]=(mu[i-1]+(ll)(mu[i]*i*i)%MOD)%MOD;
30 }
31 ll t(ll x,ll y)
32 {
33 return ((ll)(x*(x+1)/2%MOD)*(ll)(y*(y+1)/2%MOD)%MOD);
34 }
35 ll F(int n,int m)
36 {
37 int i,last; ll ans=0;
38 for(i=1;i<=n;i=last+1) {
39 last=min(n/(n/i),m/(m/i));
40 ans=(ans+(ll)(mu[last]-mu[i-1])*t(n/i,m/i)%MOD)%MOD;
41 }
42 return ans;
43 }
44 int main()
45 {
46 //freopen("in.in","r",stdin);
47 //freopen("out.out","w",stdout);
48 scanf("%d%d",&n,&m);
49 if(n>m) swap(n,m);
50 mx=n;
51 get_mu();
52 int last; ll ans=0;
53 for(int i=1;i<=n;i=last+1) {
54 last=min(n/(n/i),m/(m/i));
55 ans=(ans+((ll)(i+last)*(last-i+1)/2*F(n/i,m/i)%MOD))%MOD;
56 }
57 printf("%lld",(ans+MOD)%MOD);
58 return 0;
59 }