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
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

vector<pair<int, int> > v;
LL res[41];
int n, m;

void f(LL x) {
	for (auto [a, b] : v) {
		if (x & (1 << a) && !(x & (1 << b))) {
			x ^= (1 << a);
			x ^= (1 << b);
		}
	}
	int sum = 0;
	int start = n + 1;
	int stop = -1;
	for (int i = 0; i < n; i++) {
		if (x & (1 << i)) {
			sum++;
			start = min(start, i);
			stop = max(stop, i);
		}
	}
	if (stop - start + 1 == sum) {
		res[sum]++;
	}
}

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

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v.push_back({a, b});
	}

	for (LL x = 1; x < (1 << n); x++) {
		f(x);
	}

	for (int i = 1; i <= n; i++) {
		cout << res[i] % 2 << " ";
	}
	return 0;
}