a, n = map(int,input().split()) an=a**n M=10**7 for i in range(M): if((an%M)-(i%M)%M==0): print(M) print(i) quit()