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
#include <bits/stdc++.h>
#define ll long long
using namespace std;

struct comp {
    bool operator() (const pair<bitset<35>, int> &b1, const pair<bitset<35>, int> &b2) const {
        for(int i=0; i<35; i++){
            if(b1.first[i] < b2.first[i]) return true;
            else if(b1.first[i] > b2.first[i]) return false;
        }

        if(b1.second < b2.second) return true;
        return false;
    }
};

vector<pair<int, int>> moves;
map<pair<bitset<35>, int>, bool, comp> check; // (1, 0) = (0, 1) !!!!!!!!!
bool ans;

void dp(bitset<35> bs, int m){
    //for(int i=0; i<35; i++) cout<<bs[i]<<" "; cout<<"         "; cout<<m<<endl;
    if(check[{bs, m}]) return;
    if(m == 0){
        check[{bs, m}] = 1; ans = !ans; return;
    }

    check[{bs, m}] = 1; m--;
    if(bs[moves[m].first] == 0 && bs[moves[m].second] == 1){
        bitset<35> bs2 = bs;
        bs2[moves[m].first] = 1; bs2[moves[m].second] = 0;
        dp(bs, m); dp(bs2, m);
    } else if(bs[moves[m].first] == 1 && bs[moves[m].second] == 0){return;}
    else dp(bs, m);
}

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    int n, m; cin>>n>>m; 
    for(int i=0; i<m; i++){
        int u, v; cin>>u>>v; u--; v--;
        moves.push_back({u, v});
    }
    //---------------------
    for(int i=1; i<=n; i++){
        ans = 0;

        for(int j=0; j<=n-i; j++){
            bitset<35> bs;
            for(int k=j; k<j+i; k++) bs[k] = 1;
            dp(bs, m);
        }

        //cout<<endl;
        cout<<ans<<" ";
        //cout<<endl<<endl;
    }
    return 0;
}