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<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

inline bool zero(unsigned long long u, unsigned long long v, int pos) {
    return !(u & 1LL << pos) && !(v & 1LL << pos);
}

inline bool one(unsigned long long u, unsigned long long v, int pos) {
    return u & 1LL << pos && v & 1LL << pos;
}

inline bool both(unsigned long long u, unsigned long long v, int pos) {
    return !(u & 1LL << pos) && v & 1LL << pos;
}

inline void set_zero(unsigned long long &u, unsigned long long &v, int pos) {
    u &= ~(1LL << pos);
    v &= ~(1LL << pos);
}

inline void set_one(unsigned long long &u, unsigned long long &v, int pos) {
    u |= 1LL << pos;
    v |= 1LL << pos;
}

inline void set_both(unsigned long long &u, unsigned long long &v, int pos) {
    u &= ~(1LL << pos);
    v |= 1LL << pos;
}

struct op {
    int a, b;
};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;

    vector<op> ops(m);
    for (int i = 0; i < m; i++) {
        cin >> ops[i].a >> ops[i].b;
        ops[i].a--;
        ops[i].b--;
    }

    vector<pair<unsigned long long, unsigned long long>> src;
    src.reserve(140000);

    unsigned long long u = 0, v = 0;
    for (int i = 0; i < n; i++) {
        set_both(u, v, i);
    }
    src.push_back(make_pair(u, v));

    for (int i = 0; i < m; i++) {
        int a = ops[i].a;
        int b = ops[i].b;
        for (int i = 0, srcn = src.size(); i < srcn; i++) {
            pair<unsigned long long, unsigned long long> &s = src[i];
            unsigned long long &u = s.first;
            unsigned long long &v = s.second;
            if (both(u, v, a) && both(u, v, b)) {
                unsigned long long u2 = u;
                unsigned long long v2 = v;
                set_zero(u, v, a);
                set_zero(u, v, b);
                set_one(u2, v2, a);
                set_one(u2, v2, b);
                src.push_back(make_pair(u2, v2));
            }
            else if (both(u, v, a) && zero(u, v, b)) {
                set_zero(u, v, a);
                set_both(u, v, b);
            }
            else if (one(u, v, a) && both(u, v, b)) {
                set_both(u, v, a);
                set_one(u, v, b);
            } 
            else if (one(u, v, a) && zero(u, v, b)) {
                set_zero(u, v, a);
                set_one(u, v, b);
            } 
        }
    }
    
    vector<int> res(n);
    string s(n, '_');
    vector<bool> lzero(n, true), rzero(n, true);
    for (pair<unsigned long long, unsigned long long> &p : src) {
        for (int i = 0; i < n; i++) {
            if (zero(p.first, p.second, i)) s[i] = '0';
            else if (one(p.first, p.second, i)) s[i] = '1';
            else s[i] = '?';
        }        

        lzero[0] = s[0] == '1' ? false : true;
        for (int i = 1; i < n; i++) {
            lzero[i] = s[i] == '1' || lzero[i - 1] == false ? false : true;
        }
        
        rzero[n - 1] = s[n - 1] == '1' ? false : true;
        for (int i = n - 2; i >= 0; i--) {
            rzero[i] = s[i] == '1' || rzero[i + 1] == false ? false : true;
        }

        for (int i = 0; i < n; i++) {
            if (s[i] == '0') continue;
            for (int j = i; j < n; j++) {
                if (s[j] == '0') break;
                if (i > 0 && lzero[i - 1] == false) continue;
                if (j < n - 1 && rzero[j + 1] == false) continue;
                int k = j - i;
                res[k] += 1;
                res[k] %= 2;
            }            
        }        
    }

    for (int i : res) {
        cout << i << ' ';
    }
    cout << endl;

    return 0;
}