#include<cstdio>
#include<iostream>
const int mod=100003;
using namespace std;
inline long long get();
inline long long qpow(long long a,long long b);
long long n,m;
int main()
{
freopen("prisona.in","r",stdin);
freopen("prisona.out","w",stdout);
m=get(),n=get();
printf("%lld\n",(qpow(m,n)-m*qpow(m-1,n-1)%mod+mod)%mod);
return 0;
}
inline long long qpow(long long a,long long b)
{
long long ans=1;
while(b)
{
if(b%2)ans=(ans*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return ans;
}
inline long long get()
{
long long t=0;char c=getchar(),j=1;
while(!isdigit(c))
if(c=='-')j=-1,c=getchar();
else c=getchar();
while(isdigit(c))
t=(t<<3)+(t<<1)+c-'0',
c=getchar();
return j*t;
}