1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <bits/stdc++.h>

using namespace std;

const int N = 23;
const int M = 1000 + 7;

int n, m;
bitset<1 << N> all;
bitset<1 << N> only[N];
pair<int, int> rozkazy[M];

inline int jazda(const unsigned long long &mask, int i) {	
	if (i == 0) {
		return 1;
	}

	auto&& [a, b] = rozkazy[i];

	if ((mask & (1LL << a)) && !(mask & (1LL << b)))
		return 0;

	if ((mask & (1LL << b)) && !(mask & (1LL << a))) {
		return jazda(mask, i - 1) ^
			   jazda((mask | (1LL << a)) & (~(1LL << b)), i - 1);
	}

	return jazda(mask, i - 1);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr);

	cin >> n >> m;

	if (n > 23) {
		for (int i = 1; i <= m; i++) {
			auto &[a, b] = rozkazy[i];

			cin >> a >> b;
			a--, b--;
		}

		for (int k = 1; k <= n; k++) {
			int ans = 0;
			
			for (int i = 0; i + k - 1 < n; i++) {
				ans ^= jazda(((1LL << k) - 1) << i, m);
			}

			cout << ans << ' ';
		}
		cout << '\n';

		return 0;
	}

	for (int i = 1; i < (1 << n); i++) {
		int u = i;

		do {
			only[__builtin_ctz(u)].set(i);
			u &= u - 1;
		} while (u);
		
		all.set(i);
	}
	
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;

		auto now = (all & (only[a] & (~only[b])));

		if (now.any()) {
			all ^= now ^ ((now >> (1 << a)) << (1 << b));
		}
	}

	for (int k = 1; k <= n; k++) {
		int ans = 0;
		for (int i = 0; i + k - 1 < n; i++) {
			ans ^= all.test(((1 << k) - 1) << i);
		}
		cout << ans << ' ';
	}
	cout << '\n';
}