a,n = map(int,input().split()) M = 10 ** 9 + 7 print(M) print(poow(a,n,M))