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
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 1005;

int n, m, tab[2][N], j, a, b, prep[40], bat[40], res[40];
LL i;

bool isOk() {
	int i = 0;
	while (!prep[bat[i]]) i++;
	int j = n - 1;
	while (!prep[bat[j]]) j--;
	while (++i < j) if (!prep[bat[i]]) return false;
	return true;
}

int main() {
scanf("%d %d", &n, &m);
for (i=0;i<m;i++) scanf("%d %d", &tab[0][i], &tab[1][i]);
for (i=1;i<(1LL<<n);i++) {
	for (j=0;j<n;j++) {
		prep[j] = ((1LL<<j) & i);
		bat[j] = j;
	}
	for (j=0;j<m;j++) {
		a = tab[0][j] - 1;
		b = tab[1][j] - 1;
		if (prep[bat[a]] && !prep[bat[b]]) swap(bat[a], bat[b]);
	}
	if (isOk()) res[__builtin_popcount(i)]++;
}
for (i=1;i<=n;i++) printf("%d ", res[i] % 2);
printf("\n");
return 0;
}