n,m = map(int, input().split()) a = 0 b = 1 for i in range(n - 2): a, b = b, (a+b)%m print(b)