long long qsortMod(long long a,long long b) { long long ans=1; a%=1000000007; while(b){ if(b%2==1) ans=ans*a%1000000007; b/=2; a=a*a%1000000007; } return ans; } int main() { long long a,b; while(scanf("%lld%lld",&a,&b)&&!(a==0&&b==0)){ printf("%lld\n",qsortMod(a,b)); } return 0; }