/*
证明见PoPoQQQ课件:
https://wenku.baidu.com/view/fbec9c63ba1aa8114431d9ac.html?from=search
*/
#include<cstdio>
#include<iostream>
#define N 10000010
#define mod 20101009
#define lon long long
using namespace std;
int mu[N],prime[N],mark[N],num,n,m;
lon sum[N];
void get_prime(){
mu[1]=1;
for(int i=2;i<=n;i++){
if(!mark[i]) prime[++num]=i,mu[i]=-1;
for(int j=1;j<=num&&i*prime[j]<=n;j++){
mark[i*prime[j]]=1;
mu[i*prime[j]]=-mu[i];
if(i%prime[j]==0){
mu[i*prime[j]]=0;
break;
}
}
}
for(int i=1;i<=n;i++) sum[i]=(sum[i-1]+(1LL*mu[i]*i%mod*i%mod))%mod;
}
lon getsum(lon x,lon y){
x=(x*(x+1)/2)%mod;
y=(y*(y+1)/2)%mod;
return x*y%mod;
}
lon getf(int x,int y){
int pos;lon ans=0;
for(int i=1;i<=min(x,y);i=pos+1){
pos=min(x/(x/i),y/(y/i));
ans=(ans+(sum[pos]-sum[i-1]+mod)%mod*getsum((lon)x/i,(lon)y/i)%mod)%mod;
}
return ans;
}
int main(){
scanf("%d%d",&n,&m);
if(n>m) swap(n,m);
get_prime();
int pos;lon ans=0;
for(int i=1;i<=n;i=pos+1){
pos=min(n/(n/i),m/(m/i));
ans=(ans+1LL*(i+pos)*(pos-i+1)/2%mod*getf(n/i,m/i)%mod)%mod;
}
cout<<ans;
return 0;
}