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

const int MAXN = 40;
int ans[MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m;
	cin >> n >> m;

	vector<pair<int, int>> r(m);
	for(int i = 0; i < m;i ++) cin >> r[i].st >> r[i].nd;

	for(ll i = 1; i < (1<<n); i++){
		int bits = __builtin_popcountll(i);
		ll temp = i;
		for(int j = 0; j < m; j++){
			if((temp>>(n-r[j].st))%2==0) continue;
			if((temp>>(n-r[j].nd))%2==1) continue;
			temp ^= (1<<(n-r[j].st))+(1<<(n-r[j].nd));
		}
		bool was = false;
		if((temp>>(n-1))%2==1) was=true;;
		for(int j = n-1; j >= 1; j--) if((temp>>j)%2==0&&(temp>>(j-1))%2==1) {
			if(!was) was=true;
			else {
				was=false;
				break;
			}
		}
		if(was) ans[bits]^=1;
	}
	for(int i = 1; i <= n; i++) cout << ans[i] << ' ';
	cout << '\n';
	return 0;
}