[cpp]
#include<iostream>
#include<cstdio>
int main()
{
int a, b, res;
while(scanf("%d%d", &a, &b) != EOF && a+b){
res = 1;
for(int i = 1; i <= b; i++){
res = res*(a%1000)%1000;
}
printf("%d\n", res);
}
return 0;
}
/***********************
a*b ≡ (a%m)*(b%m) (mod m);
如果數據量比較大需要
用快速冪取模算法;
***********************/