m=1000000 a,n=map(int,input().split()) print(m) print(a**n%m)