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
125
126
127
128
129
130
131
132
133
134
135
#include<bits/stdc++.h>
using namespace std;

#define ll int64_t
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

int n, m;
pii tab[1009];

namespace N {
	bitset<(1<<27)> cnt[2];
	int ans[40];
	void solve() {
		for(int i=1;i<(1<<n);i++) {
			cnt[0][i] = 1;
		}
		for(int i=0;i<m;i++) {
			int cur =  i&1;
			int a = tab[i].st, b = tab[i].nd;
			for(int j=1;j<(1<<n);j++) {
				if(cnt[cur][j]) {
					int nj = j;
					if((j&(1<<a))&&(!(j&(1<<b)))) {
						nj ^= (1<<b);
						nj ^= (1<<a);
					}
					cnt[1-cur][nj] = 1-cnt[1-cur][nj];
					cnt[cur][j] = 0;
				}
			}
		}
		for(int i=1;i<(1<<n);i++) {
			if(!cnt[m&1][i]) continue;
			int cur = 0;
			bool tak = true;
			for(int j=0;j<n;j++) {
				if(i&(1<<j)) {
					if(cur==2) {
						tak = false;
						break;
					}
					cur = 1;
				} else if(cur==1) cur = 2;
			}
			if(tak) {
				ans[__builtin_popcount(i)]++;
			}
		}
		for(int i=1;i<=n;i++) {
			cout << (ans[i]&1) << " ";
		}
		cout << "\n";
	}
}

namespace M {
	void solve() {
		reverse(tab, tab+m);
		for(int i=1;i<=n;i++) {
			vector<ll> v[2];
			for(int j=0;j<=n-i;j++) {
				ll num = (1LL<<(j+i))-1;
				num ^= (1LL<<j)-1;
				v[0].pb(num);
			}
			for(int j=0;j<m;j++) {
				int a = tab[j].st, b = tab[j].nd;
				int cur = j&1;
				sort(all(v[cur]));
				for(int k=0;k<sz(v[cur]);k++) {
					if(k==sz(v[cur])-1||v[cur][k]!=v[cur][k+1]) {
						ll x = v[cur][k];
						if(x&(1LL<<a)) {
							if(x&(1LL<<b)) {
								v[1-cur].pb(x);
							}
						} else {
							v[1-cur].pb(x);
							if(x&(1LL<<b)) {
								x ^= (1LL<<a);
								x ^= (1LL<<b);
								v[1-cur].pb(x);
							}
						}
					}
				}
				v[cur].clear();
			}
			ll ans = 0;
			for(int j=0;j<sz(v[m&1]);j++) {
				if(j==sz(v[m&1])-1||v[m&1][j]!=v[m&1][j+1]) {
					ans++;
				}
			}
			cout << (ans&1) << " ";
		}
		cout << "\n";
	}
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
		
	cin >> n >> m;
	for(int i=0;i<m;i++) {
		cin >> tab[i].st >> tab[i].nd;
		tab[i].st--;
		tab[i].nd--;
	}
	ll LIM = 1'500'000'000;
	ll LIM2 = 500'000'000;
	ll LIM3 = 1'100'000'000;
	ll Lim = (1LL<<n)*m;
	if(Lim<=LIM2) {
		N::solve();
	} else if(m<=10) {
		M::solve();
	} else if(Lim<=LIM3) {
		N::solve();
	} else if(m<=15) {
		M::solve();
	} else if(Lim<=LIM) {
		N::solve();
	} else if(m<=20) {
		M::solve();
	} else {
		N::solve();
	}
}