a,n,t=map(int,input().split()),10**7;print(f"{t}\n{pow(a,n,t)}")