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
#include <bits/stdc++.h>
#define dbg(x) " [" << #x << ": " << (x) << "] "
using namespace std;
using ll = long long;
template<typename A, typename B>
ostream& operator<<(ostream& out, const pair<A,B>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& c) {
    out << "{";
    for(auto it = c.begin(); it != c.end(); it++) {
        if(it != c.begin()) out << ", ";
        out << *it;
    }
    return out << "}";
}

int cnt;
set<pair<int, vector<int>>> st;
void dfs(vector<int>& v, vector<pair<int, int>>& upd, int id = 0) {
    if(st.contains({id, v})) return;
    st.insert({id, v});
    if(id == upd.size()) {
        cnt ^= 1;
        return;
    }
    auto [a, b] = upd[id];
    if(v[a] == 1 && v[b] == 0) return;
    dfs(v, upd, id + 1);
    if(v[a] == 0 && v[b] == 1) {
        swap(v[a], v[b]);
        dfs(v, upd, id + 1);
        swap(v[a], v[b]);
    }
}

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

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> upd;
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        upd.push_back({a, b});
    }
    reverse(upd.begin(), upd.end());

    for(int len = 1; len <= n; len++) {
        st.clear();
        cnt = 0;
        for(int i = 0; i + len <= n; i++) {
            vector<int> v(n);
            for(int j = i; j < i + len; j++) v[j] = 1;
            dfs(v, upd);
        }
        if(len > 1) cout << " ";
        cout << cnt;
    }
    cout << endl;

    return 0;
}