#include "bits/stdc++.h"
#define ll long long
using namespace std;
const int mod = 100003;
ll n,m;
ll ss(ll x, ll y){
ll ans = 1 ;
while (y){
if(y&1) ans = ans * x % mod;
x = x*x%mod;
y >>=1;
}
return ans;
}
int main()
{
cin >> m >> n;
ll res = (ss(m,n) - m*ss(m-1,n-1)%mod+mod)%mod;
cout << res << endl;
return 0;
}