#include<iostream>
#include<cstdio>
using namespace std;
//result = (m%100003)^n %(100003) - m*(m-1)^(n-1)%100003
//a^(2n)%c = (a^n%c)^2%c
// a*b % c = a%c * b%c % c
//a^(2n+1)%c = a^n * a^n *a % c = (a^n%c)^2%c * a%c % c
long long m;
long long resulta(long long n){
if(n==1)
return m;
else if(n&1){
long long r = resulta(n/2);
r *= r;
r %= 100003;
r = r*m%100003;
return r;
}else{
long long r = resulta(n/2);
r *= r;
r %= 100003;
return r;
}
}
long long resultb(long long n){
m--;
return resulta(n-1)*(m+1)%100003;
}
int main(){
freopen("prisona.in","r",stdin);
freopen("prisona.out","w",stdout);
long long n;
cin>>m>>n;
m%=100003;
int a = resulta(n),b = resultb(n);
if(a>b)cout<<a-b;
else cout<<100003+a-b;
fclose(stdin);fclose(stdout);
return 0;
}