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
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

vector<map<long long, int>>M(1001);
vector<pair<int, int>>G;

int rekurencja(long long x, int it) {
	if (it == G.size()) return 1;
	if (M[it].find(x) != M[it].end()) return M[it][x];

	long long a = G[it].first - 1;
	long long b = G[it].second - 1;

	long long AA = (x & (1ll << a));
	long long BB = (x & (1ll << b));
	if (AA) AA = 1;
	if (BB) BB = 1;

	if (AA && !BB) return 0;
	int RES = 0;
	if (AA != BB) {
		RES = rekurencja(x, it + 1);
		x ^= (1ll << b);
		x |= (1ll << a);
	}
	int RS = rekurencja(x, it + 1);
	if (AA != BB) {
		x ^= (1ll << a);
		x |= (1ll << b);
	}
	return M[it][x] = (RES + RS) % 2;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, m;
	cin >> n >> m;
	G = vector<pair<int, int>>(m);
	for (auto& p : G) cin >> p.first >> p.second;
	reverse(G.begin(), G.end());
	for (int k = 1; k <= n; k++) {
		int rs = 0;

		for (int i = 0; i <= n - k; i++) {
			int j = i + k - 1;
			long long x = 0;
			for (int l = i; l <= j; l++) x |= 1ll << l;
			rs += rekurencja(x, 0);
		}
		cout << rs % 2 << ' ';
	}

	return 0;
}