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
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define FOR(i,l,r)for(int i=(l);i<=(r);++i)
#define REP(i,n)FOR(i,0,(n)-1)
#define ssize(x)int(x.size())
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

int n, m;
vector<pair<int, int>> edges;
vector<LL> ans(n + 1), state(n, -1);
void rek(int p) {
	debug(p, state);
	if (p == m) {
		debug(state);
		int mn = n;
		int mx = 0;
		REP (i, n)
			if (state[i] == 1) {
				mn = min(mn, i);
				mx = max(mx, i);
			}
		if (mn == n) {
			auto dolicz = [&](int w) {
				FOR (i, 1, w)
					ans[i] += w - i + 1;
			};
			int len = 0;
			REP (i, n) {
				if (state[i] == 0) {
					dolicz(len);
					len = 0;
				}
				else {
					assert(state[i] == -1);
					++len;
				}
			}
			dolicz(len);
			return;
		}
		int k = mx - mn + 1;
		FOR (i, mn, mx)
			if (state[i] == 0)
				return;
		int lf = 0;
		while (mn && state[mn - 1] == -1) {
			--mn;
			++lf;
		}
		int rg = 0;
		while (mx + 1 < n && state[mx + 1] == -1) {
			++mx;
			++rg;
		}
		REP (i, lf + 1)
			REP (j, rg + 1)
			++ans[k + i + j];
		return;
	}
	auto [l, r] = edges[p];
	if (state[l] == -1) {
		if (state[r] == -1) {
			state[l] = state[r] = 0;
			rek(p + 1);
			state[l] = state[r] = 1;
			rek(p + 1);
			state[l] = state[r] = -1;
		}
		else if (state[r] == 0) {
			swap(state[l], state[r]);
			rek(p + 1);
			swap(state[l], state[r]);
		}
		else {
			rek(p + 1);
		}
	}
	else if (state[r] == -1) {
		if (state[l] == 0) {
			rek(p + 1);
		}
		else {
			swap(state[l], state[r]);
			rek(p + 1);
			swap(state[l], state[r]);
		}
	}
	else {
		if (state[l] && !state[r]) {
			swap(state[l], state[r]);
			rek(p + 1);
			swap(state[l], state[r]);
		}
		else
			rek(p + 1);
	}
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	edges.resize(m);
	for (auto &[l, r] : edges) {
		cin >> l >> r;
		--l;
		--r;
	}
	ans.resize(n + 1);
	state.resize(n + 1, -1);
	rek(0);
	FOR (i, 1, n) {
		if (i > 1)
			cout << ' ';
		cout << ans[i] % 2;
	}
	cout << endl;
}