人见人爱A^B
#include<stdio.h>
int main()
{
int a,b;
while(scanf("%d %d",&a ,&b) != EOF){
if(a==0 && b==0){
break;
}
int i,temp=1;
if(b==0){
printf("1");
}else{
for(i=1; i<=b; i++){
temp = temp * a;
temp = temp % 1000;
}
printf("%d\n",temp);
}
}
return 0;
}