1 #include<cstdio>
2 #include<cstring>
3 #include<cmath>
4 #include<algorithm>
5
6 #define maxn 10000001
7
8 #define mod 20101009
9
10 using namespace std;
11
12 long long mu[maxn],prime[maxn],mx,mi;
13
14 long long f[maxn],ans=0;
15
16 bool is_prime[maxn];
17
18 long long sum(long long x,long long y){return (x*(x+1)/2%mod)*(y*(y+1)/2%mod)%mod;}
19
20 void mu_choice()
21 {
22 long long b=0;
23 mu[1]=1;
24 for(long long i=2;i<=mx;i++)
25 {
26 if(!is_prime[i])mu[i]=-1,prime[++b]=i;
27 long long j=1,t=2*i;
28 while(j<=b&&t<=mx)
29 {
30 is_prime[t]=1;
31 if(i%prime[j]==0)
32 {
33 mu[t]=0;
34 break;
35 }
36 mu[t]=-mu[i];
37 t=prime[++j]*i;
38 }
39 }
40 for(long long i=1;i<=mi;i++)
41 f[i]=(f[i-1]+(i*i%mod*mu[i]))%mod;
42 }
43
44 long long F(long long n,long long m)
45 {
46 long long re=0,last;
47 if(n>m)swap(n,m);
48 for(long long i=1;i<=n;i=last+1)
49 {
50 last=min(n/(n/i),m/(m/i));
51 re=(re+(f[last]-f[i-1])*sum(n/i,m/i)%mod)%mod;
52 }
53 return re;
54 }
55
56 int main()
57 {
58 #ifndef ONLINE_JUDGE
59 freopen("2154.in","r",stdin);
60 freopen("2154.out","w",stdout);
61 #endif
62 long long n,m;
63 scanf("%lld%lld",&n,&m);
64 mx=max(n,m);
65 mi=min(n,m);
66 mu_choice();
67 long long last;
68 for(long long i=1;i<=mi;i=last+1)
69 {
70 last=min(n/(n/i),m/(m/i));
71 ans+=((last-i+1)*(last+i)/2%mod*F(n/i,m/i)%mod);
72 ans%=mod;
73 }
74 printf("%lld",(ans+mod)%mod);
75 return 0;
76 }