A, N = map(int, input().split()) M = 10 print(M) print((A**N)%M)