1 #include<cstdio>
2 #include<cstdlib>
3 #include<cstring>
4 #include<iostream>
5 #include<algorithm>
6 #include<queue>
7 #include<cmath>
8 using namespace std;
9 #define Mod 20101009
10 #define Maxn 10000010
11 #define LL long long
12
13 LL mu[Maxn],pri[Maxn],h[Maxn],pl;
14 bool q[Maxn];
15
16 LL mymin(LL x,LL y) {return x<y?x:y;}
17
18 void get_mu(LL mx)
19 {
20 pl=0;
21 memset(q,1,sizeof(q));
22 mu[1]=1;
23 for(LL i=2;i<=mx;i++)
24 {
25 if(q[i])
26 {
27 pri[++pl]=i;
28 mu[i]=-1;
29 }
30 for(LL j=1;j<=pl;j++)
31 {
32 if(i*pri[j]>mx) break;
33 q[i*pri[j]]=0;
34 if(i%pri[j]==0) mu[i*pri[j]]=0;
35 else mu[i*pri[j]]=-mu[i];
36 if(i%pri[j]==0) break;
37 }
38 }
39 h[1]=(mu[1]*1*1)%Mod;
40 for(LL i=2;i<=mx;i++) h[i]=(h[i-1]+mu[i]*i*i)%Mod;
41 }
42
43 LL get_g(LL x,LL y)
44 {
45 return ( ( ((x+1)*x/2)%Mod )*( ((y+1)*y/2)%Mod ) )%Mod;
46 }
47
48 LL get_f(LL n,LL m)
49 {
50 LL t;
51 if(n>m) t=n,n=m,m=t;
52
53 LL sq=(LL)ceil(sqrt((double)m));
54
55 LL ans=0;
56 for(LL i=1;i<=mymin(n,sq);i++)
57 {
58 ans=( ans+((mu[i]*i*i)%Mod)*get_g(n/i,m/i) )%Mod;
59 }
60 for(int i=sq+1;i<=n;)
61 {
62 int x=n/i,y=m/i;
63 int r1=n/x+1,r2=m/y+1;
64 if(r1>n+1) r1=n+1;
65 if(r2>n+1) r2=n+1;
66 int r=mymin(r1,r2);
67 ans=(ans+ ((h[r-1]+Mod-h[i-1])%Mod)*get_g(x,y) )%Mod;
68 i=r;
69 }
70 return ans;
71 }
72
73 LL get_ans(int n,int m)
74 {
75 LL ans=0;
76
77 LL sq=(LL)ceil(sqrt((double)m));
78 for(LL i=1;i<=mymin(sq,n);i++)
79 {
80 ans=(ans+i*get_f(n/i,m/i) )%Mod;
81 }
82
83 for(LL i=sq+1;i<=n;)
84 {
85 LL x=n/i,y=m/i;
86 LL r1=n/x+1,r2=m/y+1;
87 LL r=mymin(r1,r2);
88 if(r>m+1) r=m+1;
89 ans=( ans+(((r-i)*(i+r-1)/2)%Mod)*get_f(x,y) )%Mod;
90 i=r;
91 }
92 return ans;
93 }
94
95 int main()
96 {
97 int T;
98 T=1;
99
100 while(T--)
101 {
102 LL n,m,t;
103 scanf("%lld%lld",&n,&m);
104 if(n>m) t=n,n=m,m=t;
105 get_mu(m);
106
107 LL ans=get_ans(n,m);
108
109 printf("%lld\n",ans);
110 }
111 return 0;
112 }