#include<bits/stdc++.h>
using namespace std;
#define int long long
const int P=100003;

int power(int a,int b,int p){
	int ans=1;
	while(b>0){
		if(b&1==1){
			ans=ans*a%p;
		}
		a=a*a%p;
		b=b>>1;
	}
	return ans;
}

int n,m;


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	
	int res=(power(m,n,P)%P-m%P*power(m-1,n-1,P)%P+P)%P;
	
	cout<<res<<endl;

    return 0;
}