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
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 2010
#define maxa 30
#define result_t pair<bool, pair<int,char>>

vector<pair<int,int>> orders;
unordered_set<ll> results, tmp;

ll initialize(int i, int x) {
    ll mask = 0;
    for (int j = 0; j < x; ++j) {
        ll pot = i + j;
        mask += (ll)(1LL<<pot);
    }
    return mask;
}

void apply_one(ll mask, ll a, ll b) {
    bool is_a = ((mask & (1LL << a))) != 0;
    bool is_b = ((mask & (1LL << b))) != 0;
    if (!is_a && is_b) {
        //cout << "A" << mask << endl;
        results.insert(mask ^ ((1LL << a) + (1LL << b)));
        results.insert(mask);
    }
    else if (is_a == is_b) {
        results.insert(mask);
    }
}

// ll solve_one(int i, int x, int n) {
//     ll mask = initialize(i, x);
//     for (auto order : orders) {
//         mask = apply_one(mask, order.first, order.second);
//     }
//     cout << mask << endl;
//     return mask;
// }

int solve(int x, int n) {
    for (int i = 0; i + x <= n; ++i) {
        results.insert(initialize(i, x));
    }
    for (auto order: orders) {
        //cout << "NUMBERS: ";
        tmp.clear();
        results.swap(tmp);
        for (auto it = tmp.begin(); it != tmp.end(); ++it) {
            //cout << *it << " ";
            apply_one(*it, order.first, order.second);
        }
        //cout << endl;
    }
    int res = (int)results.size() % 2;
    results.clear();
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,a,b;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        orders.push_back({a-1,b-1});
    }
    reverse(orders.begin(), orders.end());
    //solve(1,n);
    for (int i = 1; i <= n; ++i) {
        string c = i == n ? " \n" : " ";
        //solve(i,n);
        cout << solve(i, n) << c;
    }
}