a,n = map(int,input().split()) mod = 10**9+7 ans = pow(a,n,mod) print(mod) print(ans)