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