n, m = map(int, input().split()) n = min(n, m+3) f = 1 % m for i in range(1, n+1): f = f * i % m print(f)