import functools import numpy as np n,m= map(int,input().split()) # @functools.lru_cache(maxsize = None) # # def func(p): # if p==1 : return np.mod(arr,m) # if p%2==1: # return np.mod(func(p-1)*arr,m) # else: # return np.mod(func(p//2)*func(p//2),m) # # arr = np.mat([[0,1],[1,1]]) # bb = np.mat([0,1])*func(n-1) # print(bb.item((0,0))) a = 0 b = 1 for i in range(n-2): a,b = (b,(a+b)%m) print(b)