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