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
59
60
61
62
63
64
65
// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define PB emplace_back
#define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) { rep(i, 0, siz(n) - 1) cerr << n[i] << " \n"[i == siz(n) - 1]; }

int a, b, s[1 << 20], t[1 << 20], top = 1;
bool ans[36];

bool f(int n, int m) {return (n >> m) & 1;}
void calc(int &n, int &m, int i, int j) {
	if(f(n, i) && f(n, j)) {
		if(f(m, i) > f(m, j)) m ^= 1ll << i, m ^= 1ll << j;
	}
	else if(!f(n, i) && f(n, j)) {
		if(!f(m, j)) n ^= 1ll << i, n ^= 1ll << j;
	}
	else if(f(n, i) && !f(n, j)) {
		if(f(m, i)) n ^= 1ll << i, n ^= 1ll << j, m ^= 1ll << i, m ^= 1ll << j;
	}
	else {
		n ^= 1ll << i, n ^= 1ll << j;
		s[++top] = n, t[top] = m ^ (1ll << i) ^ (1ll << j);
	}
}

signed main() {
	// freopen(".in", "r", stdin);
	// freopen(".out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> a >> b;
	if(!b) {
		rep(i, 1, a) cout << f(a - i + 1, 0) << ' ';
		return 0;
	}
	int x, y;
	rep(i, 1, b) {
		cin >> x >> y;
		--x, --y;
		if(x == y) continue;
		const int lim = top;
		rep(j, 1, lim) calc(s[j], t[j], x, y);
	}
	rep(i, 1, top) {
		rep(j, 0, a - 1) rep(k, j, a - 1) {
			if(f(s[i], k) && !f(t[i], k)) break;
			if((((t[i] >> j) & ((1ll << (k - j + 1)) - 1)) << j) == t[i]) {
				ans[k - j + 1] ^= 1;
			}
		}
	}
	rep(j, 1, a) cout << ans[j] << ' ';
	return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
}