#include<bits/stdc++.h>
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#endif
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define each(x,v) for(auto&x:v)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
using namespace std;
int P;
inline int ad(int x,int y){return x+y>=P?x+y-P:x+y;}
inline void uad(int&x,int y){(x+=y)>=P&&(x-=P);}
inline int su(int x,int y){return x-y<0?x-y+P:x-y;}
inline void usu(int&x,int y){(x-=y)<0&&(x+=P);}
inline int mu(int x,int y){return 1ULL*x*y%P;}
const int N=505;
int n,f[2][N][N],C[N][N]; // f[i][j][k]: 前 i 个，j 个 tree1 非叶子，k 个 tree2 的点没选父亲
int main(){
	freopen("tree.in","r",stdin);
	freopen("tree.out","w",stdout);
	scanf("%d%d",&n,&P);
	rep(i,0,N-1){
		C[i][0]=1;
		rep(j,1,i)C[i][j]=ad(C[i-1][j-1],C[i-1][j]);
	}
	f[1][1][0]=1;
	rep(i,2,n){
		memset(f[i&1],0,sizeof(f[i&1]));
		// tree2 is leaf
		rep(j,1,i-1){
			rep(k,0,i-2){
				uad(f[i&1][j+1][k+1],mu(j,f[(i-1)&1][j][k]));
				usu(f[i&1][j][k+1],mu(j,f[(i-1)&1][j][k]));
			}
		}
		// tree2 is no leaf
		rep(j,1,i-1){
			rep(k,0,i-2){
				rep(take,0,k+1){
					uad(f[i&1][j][k-take+1],mu(j,mu(f[(i-1)&1][j][k],C[k+1][take])));
				}
				int take=0;
				usu(f[i&1][j][k+1],mu(j,f[(i-1)&1][j][k]));
			}
		}
		static int g[1010];
		memset(g,0,sizeof(g));
		rep(j,1,i){
			rep(k,0,n)uad(g[k],f[i&1][j][k]);
		}
		D("i=%d\n",i);
		rep(x,1,10){
			int y=0;
			per(k,n,0){
				y=ad(mu(y,x),g[k]);
			}
			D("%d ",y);
		}
		D("\n");
	}
	return 0;
}
