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 MAXN 36
#define MAXM 1011

using namespace std;

int n, m;
pair<int, int> orders[MAXM];
int bCnt;
int onbCnt;
int w[MAXN];
bool o;

int main() {
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &orders[i].first, &orders[i].second);
		orders[i].first--;
		orders[i].second--;
	}
	
	bCnt = 0;
	int s = (1 << n) - 1;;
	for (int i = 0; i < s; i++) {
		o = true;
		bCnt++;
		bitset<MAXN> b(bCnt);
		onbCnt = b.count();
		for (int j = 0; j < m; j++) {
			if (b[orders[j].first] == true && b[orders[j].second] == false) {
				b[orders[j].first].flip();
				b[orders[j].second].flip();
			}
		}
		int c = 0;
		for (int j = 0; j < n; j++) {
			if (b[j] == true && c == 1);
			else if (b[j] == false && c == 0);
			else if (b[j] == false && c == -1);
			else if (b[j] == true && c == 0) {
				c = 1;
			} else if (b[j] == true && c == -1) {
				o = false;
			} else if (b[j] == false && c == 1) {
				c = -1;
			} 
		}
		if(o == true) {
			w[onbCnt]++;
		}
	}
	for (int i = 1; i <= n; i++) {
		printf("%d ", (w[i] & 1));
	}
	printf("\n");
	return 0;
}