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
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<(int)b;++i)
#define FORD(i,a,b) for(int i=a;i>=(int)b;--i)
#define PB push_back
#define EB emplace_back
#define FI first
#define SE second
#define umap unordered_map
#define uset unordered_set
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define vpii vector<pii>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ALL(X) (X).begin(),(X).end()
#ifndef DEBUG
#define endl (char)10
#endif
using namespace std;
using ll = long long;
using ld = long double;

template <class T>
istream& operator>> (istream& is, vector<T>& vec){
    FOR(i,0,vec.size()) is >> vec[i];
    return is;
}
template <class T>
ostream& operator<< (ostream& os, vector<T>& vec){
    for(auto& t : vec) os << t << " ";
    return os;
}
template<class T, class U>
ostream& operator<< (ostream& os, const pair<T, U>& p){
    os << p.FI << " " << p.SE;
    return os;
}
template<class T, class U>
istream& operator>> (istream& is, pair<T, U>& p){
    is >> p.FI >> p.SE;
    return is;
}

const int N = 35;

using S = bitset<2 * N>;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    S init((1LL << N) - 1);
    init <<= N;
    vector<S> V{init};
    while(m--){
        int x, y;
        cin >> x >> y;
        x--; y--;
        int mlim = V.size();
        FOR(i,0,mlim){
            if (V[i].test(N + x)){
                if (V[i].test(N + y)){
                    V[i].reset(N + x);
                    V[i].reset(N + y);
                    S cp = V[i];
                    cp.set(x);
                    cp.set(y);
                    V.PB(cp);
                } else if (!V[i].test(y)) {
                    V[i].reset(N + x);
                    V[i].set(N + y);
                }
            } else if (V[i].test(x)){
                V[i][x + N] = V[i][y + N];
                V[i][x] = V[i][y];
                V[i].reset(y + N);
                V[i].set(y);
            }
        }
    }
    vi ans(n, 0);
    for (auto& p : V){
        S pew = p;
        pew <<= N;
        pew >>= N;
        if(pew.any()){
            int first = pew._Find_first();
            int last = first;
            int clast;
            while((clast = pew._Find_next(last)) != pew.size()) last = clast;
            bool ok = true;
            FOR(i,first+1,last) if (!p.test(i) && !p.test(i + N)){
                ok = false;
                break;
            }
            if(ok){
                int pp = first - 1;
                while(pp >= 0 && p.test(pp + N)) pp--;
                int po = last + 1;
                while(po < n && p.test(po + N)) po++;
                pp = first - 1 - pp;
                po -= last + 1;
                if (pp < po) swap(pp, po);
                int x = last - first;
                int kkk = po + pp;
                //cout << p << ": " << kkk << " ";
                FORD(i,kkk,0){
                    int ile = min({i + 1, kkk - i + 1, po + 1});
                    //cout << "(" << x + i << " " << ile << ") ";
                    ans[x + i] ^= (ile % 2);
                }
                //cout << endl;
            }
        } else {
            int prv = 0;
            FOR(i,0,n + 1){
                if(i == n || !p.test(i + N)){
                    int ile = i - prv;
                    //cout << "Group of " << ile << endl;
                    prv = i + 1;
                    if (ile > 0){
                        for(int a = ile - 1; a >= 0; a -= 2) ans[a] ^= 1;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}