#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=1e7+5,MOD=20101009;
inline int read() {
char c=getchar();
int x=0,f=1;
while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=-1;c=getchar();}
while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘;c=getchar();}
return x*f;
}
int n,m;
bool notp[N];int p[N];
ll s[N],mu[N];
void sieve(int n){
mu[1]=1;
for(int i=2;i<=n;i++){
if(!notp[i]) p[++p[0]]=i,mu[i]=-1;
for(int j=1;j<=p[0]&&i*p[j]<=n;j++){
int t=i*p[j];
notp[t]=1;
if(i%p[j]==0){
mu[t]=0;
break;
}
mu[t]=-mu[i];
}
}
for(ll i=1;i<=n;i++)
s[i]=(s[i-1]+(i*i*mu[i])%MOD)%MOD;
}
inline ll S(ll x,ll y){
return ((x*(x+1)/2)%MOD)*((y*(y+1)/2)%MOD)%MOD;
}
ll f(ll n,ll m){
ll ans=0,r=0;
for(ll d=1;d<=n;d=r+1){
r=min(n/(n/d),m/(m/d));
ans=(ans+(s[r]-s[d-1])*S(n/d,m/d)%MOD)%MOD;
}
return ans;
}
int main() {
n=read();
m=read();
sieve(n);
if(n>m) swap(n,m);
ll ans=0,r=0;
for(ll d=1;d<=n;d=r+1){
r=min(n/(n/d),m/(m/d));
ans=(ans+f(n/d,m/d)*((r-d+1)*(r+d)/2)%MOD)%MOD;
}
printf("%lld",(ans+MOD)%MOD);
}