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