#include<iostream>
using namespace std;
int pow(int a,int b,int c)
{
int ans=1;
while(b)
{
if(b&1)
ans=(ans*a)%c;
a=(a*a)%c;
b=b/2;
}
return ans;
}
int main()
{
int a,b,c=10003;
while(cin>>a>>b)
{
cout<<pow(a,b,c)<<endl;
}
return 0;
}