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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ssize(a) ((int)(a.size()))
#pragma GCC optimize ("O3")


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

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>>roz(m);
    vector<ll>pot(n);
    pot[0] = 1;
    for(int i = 1; i < n; ++i)
        pot[i] = pot[i - 1] << 1;
    for(int i = 0; i < m; ++i)
    {
        cin >> roz[i].first >> roz[i].second;
        --roz[i].first;
        --roz[i].second;
    }
    reverse(roz.begin(), roz.end());
    for(int dl = 1; dl <= n; ++dl)
    {
        unordered_map<ll, char>ile[2];
        vector<ll>stn[2];
        for(int pocz = 0; pocz + dl - 1 < n; ++pocz)
        {
            ll msk = 0;
            for(int j = 0; j < dl; ++j)
                msk += pot[pocz + j];
            ile[0][msk] = 1;
            stn[0].push_back(msk);
        }
        for(int i = 0; i < m; ++i)
        {
            ile[!(i & 1)].clear();
            stn[!(i & 1)].clear();
            for(auto j:stn[i & 1])
            {
                if(ile[i & 1][j] != 1)
                    continue;
                bool k1 = (j & pot[roz[i].first]);
                bool k2 = (j & pot[roz[i].second]);
                if(k1 == 0 && k2)
                {
                    ll pj = j;
                    if(ile[!(i & 1)][pj] == 0)
                    {
                        stn[!(i & 1)].push_back(pj);
                        ile[!(i & 1)][pj] = 1;
                    }
                    else if(ile[!(i & 1)][pj] == 1)
                        ile[!(i & 1)][pj] = 2;

                    pj = j - pot[roz[i].second] + pot[roz[i].first];
                    if(ile[!(i & 1)][pj] == 0)
                    {
                        stn[!(i & 1)].push_back(pj);
                        ile[!(i & 1)][pj] = 1;
                    }
                    else if(ile[!(i & 1)][pj] == 1)
                        ile[!(i & 1)][pj] = 2;
                }     
                else if(k1 == k2)
                {
                    if(ile[!(i & 1)][j] == 0)
                    {
                        stn[!(i & 1)].push_back(j);
                        ile[!(i & 1)][j] = 1;
                    }
                    else if(ile[!(i & 1)][j] == 1)
                        ile[!(i & 1)][j] = 2;
                }
            }
        }
        int odp = 0;
        for(ll i: stn[m & 1])
            if(ile[m & 1][i] == 1)
                odp = (odp + 1) & 1;
        cout << odp << ' ';
    }
    return 0;
}