def mulm(a,b): return ((a % 10) * (b % 10)) % 10 N = int(input()) M = int(input()) n = N % 10 k = N % 10 for i in range(M-1): k = mulm(n,k) print(k)