#include <bits/stdc++.h>

using namespace std;

int N, M;

// INPUT

namespace sub1 {

long long f[1 << 20], ans;

void inc(long long& x, long long y) { x = (x + y) % M; }

void main() {
	f[1] = 1;
	for (int i = 1; i < N; ++i) {
		for (int j = 1 << i - 1; j < 1 << i; ++j) {
			int cnt = 0, tmp = j;
			while (tmp) {
				inc(f[j - (tmp & -tmp) | 1 << i], f[j]);
				tmp -= tmp & -tmp;
				++cnt;
			}
			inc(f[j | 1 << i], f[j] * (i - cnt));
		}
		ans = 0;
		for (int j = 1 << i; j < 1 << i + 1; ++j) {
			int tmp = j, k = 0;
			while (tmp) {
				k = k << 1 | !(tmp & 1);
				tmp >>= 1;
			}
			inc(ans, f[j] * f[k]);
		}
		printf("%lld\n", ans);
	}
}

}

// 20 PTS

int main() {
	freopen("tree.in", "r", stdin);
	freopen("tree.out", "w", stdout);
	scanf("%d%d", &N, &M);
	if (N <= 20) sub1::main();
	fclose(stdin);
	fclose(stdout);
	return 0;
}
