#include<stdio.h> #define MOD 1000000007 typedef long long ll; ll qsortMod(ll a,ll b) { ll ans=1; a%=MOD; while(b){ if(b&1) ans=ans*a%MOD; b>>=1; a=a*a%MOD; } return ans; } int main() { ll a,b; while(scanf("%lld%lld",&a,&b)&&!(a==0&&b==0)){ printf("%lld ",qsortMod(a,b)); } return 0; }