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
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;

const int N = 40;
int n, m;
vector<pair<int,int>> change;
int res[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
	cin >> n >> m;
	for (int i=0; i<m; i++){
		int a, b; cin >> a >> b;
		a--; b--;
		change.push_back({a, b});
	}
 
	for (int msk=1; msk<(1<<n); msk++){
		vector<int> cur;
		int cnt = 0;
		for (int i=0; i<n; i++){
			if (msk & (1<<i)) cnt++;
			cur.push_back(msk & (1<<i) ? 1 : 0);
		}
		reverse(cur.begin(), cur.end());
		//cout << msk << ": ";
		//for (auto i : cur) cout << i << ' ';
		//cout << '\n';
		
		for (auto [a, b] : change){
			if (cur[a] == 1 && cur[b] == 0) swap(cur[a], cur[b]);
		}
		vector<int> ones;
		bool ok = true;
		for (int i=0; i<n; i++) if (cur[i] == 1) ones.push_back(i);
		for (int i=1; i<(int)ones.size(); i++) if (ones[i] - ones[i-1] > 1) ok = false;
		if (ok) res[cnt]++;
	}
 
	for (int i=1; i<=n; i++) cout << res[i] % 2 << ' ';
	cout << '\n';
	
    return 0;
}
/*

4 4
4 1
1 2
3 4
1 4

*/