#include <iostream>
#define ll long long
using namespace std;
ll m,n;
ll quickpower(ll x)
{
if (!x) return 1;
ll ls=quickpower(x>>1);
if (x&1) return (ls*ls*m)%100003;
else return (ls*ls)%100003;
}
int main()
{
cin>>m>>n;
m%=100003;
ll ans=quickpower(n);
m--;
ans-=((m+1)*quickpower(n-1))%100003;
cout<<(ans+100003)%100003<<endl;
return 0;
}