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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <vector>
#include <iostream>
#include <sstream>
#include <math.h>
#include <sys/time.h>
#include <cstdlib>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <fstream>
#include <set>
#include <map>
#include <iomanip>
#include <queue>

#define FOR(i,a,b)  for(__typeof(b) i=(a);i<(b);++i)
#define REP(i,a)    FOR(i,0,a)
#define FOREACH(x,c)   for(__typeof(c.begin()) x=c.begin();x != c.end(); x++)
#define ALL(c)      c.begin(),c.end()
#define CLEAR(c)    memset(c,0,sizeof(c))
#define SIZE(c) (int) ((c).size())

#define PB          push_back
#define MP          make_pair
#define X           first
#define Y           second

#define ULL         unsigned long long
#define LL          long long
#define LD          long double
#define II         pair<int, int>
#define DD         pair<double, double>
#define FF          pair<float,float>

#define VC	    vector
#define VI          VC<int>
#define VVI         VC<VI>
#define VVVI        VC<VVI>
#define VD          VC<double>
#define VS          VC<string>
#define VII         VC<II>
#define VDD         VC<DD>
#define VFF         VC<FF>
#define VVD         VC<VD>
#define VVVD        VC<VVD>
#define VULL         VC<ULL>
#define ULL2         pair<ULL,ULL>
#define VULL2       VC<ULL2>

#define DB(a)       cerr << #a << ": " << a << endl;

using namespace std;

template<class T> void print(VC < T > v) {cerr << "[";if (SIZE(v) != 0) cerr << v[0]; FOR(i, 1, SIZE(v)) cerr << "," << v[i]; cerr << "]\n";}
template<class T> string i2s(T &x) { ostringstream o; o << x; return o.str(); }
VS split(string &s, char c = ' ') {VS all; int p = 0, np; while (np = s.find(c, p), np >= 0) {all.PB(s.substr(p, np - p)); p = np + 1;} if (p < SIZE(s)) all.PB(s.substr(p)); return all;}

int main(int argc, char *argv[]){
    VULL m1(35);
    REP(i,35) m1[i] = 1ULL << i;

    int N,M;
    cin >> N >> M;
    VULL2 states;
    states.PB(MP(0ULL,0ULL));
    VULL2 states2;
    int a,b;
    REP(i,M){
        cin >> a >> b;
        a--; b--;
        ULL m = m1[a]+m1[b];
        for(auto s : states){
            if ((m & s.X) == 0){
                states2.PB(MP(s.X | m, s.Y));
                states2.PB(MP(s.X | m, s.Y | m));
            } else if ((m & s.X) == m){
                if ( ((m1[a] & s.Y) != 0) && ((m1[b] & s.Y) == 0) )
                    states2.PB(MP(s.X,s.Y^m));
                else
                    states2.PB(s);
            } else{ // exactly 1 is 1
                if ( ( (s.Y & m) == 0 ) && (s.X & m1[b]) )
                    states2.PB(MP(s.X^m,s.Y));
                else if ( ( (s.Y & m) != 0 ) && (s.X & m1[a]) )
                    states2.PB(MP(s.X^m,s.Y^m));
                else
                    states2.PB(s);
            }
        }
        states.swap(states2);
        states2.clear();
        //for(auto s : states) cout << s.X << " " << s.Y << endl;
        //cout << "================" << endl;
    }
    VI cnt(N+1,0);
    string c(N,'?');
    c += 'X';
    for(auto s : states){
        REP(i,N){
            if (s.Y % 2)
                c[i] = '1';
            else if (s.X % 2)
                c[i] = '0';
            else
                c[i] = '?';
            s.X /= 2;
            s.Y /= 2;
        }
        //cout << c << endl;

        int min1 = N;
        int max1 = -1;
        REP(i,N) 
            if (c[i] == '1'){
                min1 = min(min1,i);
                max1 = max(max1,i);
            }
        //cout << min1 << " " << max1 << endl;
        if (min1 == N){
            // no 1s
            int minQ = -1;
            REP(i,N+1){
                if (c[i] != '?' && minQ != -1){
                    int maxQ = i-1;
                    FOR(j,1,maxQ-minQ+2){
                        cnt[j] = (cnt[j]+ (maxQ+2-j-minQ) )%2;
                    }
                    minQ = -1;
                } else if (c[i] == '?' && minQ == -1)
                    minQ = i;
            }
        }
        // there are 1s
        int ok = 1;
        FOR(i,min1,max1)
            if (c[i] == '0')
                ok = 0;
        if (!ok)
            continue;
        int minQ = min1;
        int maxQ = max1;
        while (minQ > 0 && (c[minQ-1] == '?'))
            minQ--;
        while (maxQ < N-1 && (c[maxQ+1] == '?'))
            maxQ++;

        //cout << min1 << " " << max1 << " " << minQ << " " << maxQ << endl;
        FOR(i,max1-min1+1,maxQ-minQ+2){
            //cout << i << endl;
            int minS = max(minQ,max1-i+1);
            int maxS = min(min1,maxQ-i+1);
            cnt[i] = (cnt[i] + maxS-minS+1)%2;
        }
    }

    FOR(i,1,N+1) cout << cnt[i]%2 << " "; 
    cout << endl;
    return 0;
}