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