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

using namespace std;

int n, m;
struct Order{
    int a, b;
};

vector<Order> orders;

vector<vector<vector<bool>>> posibilities;

void generate_posibilities(int n){
    posibilities.assign(n + 1, vector<vector<bool>>());
    for(int i = 0; i < 1<<n; ++i){
        int pop_cnt = __builtin_popcount(i);
        posibilities[pop_cnt].push_back(vector<bool>());
        for(int j = 0; j < n; ++j){
            posibilities[pop_cnt].back().push_back(i & (1<<j));
        }
    }
}

vector<bool> get_posibility(int n, int i){
    vector<bool> result;
    for(int j = 0; j < n; ++j){
        result.push_back(i & (1<<j));
    }
    return result;
}

int get_posibility_value(vector<bool> pos){
    int result = 0;
    for(int i = 0; i < pos.size(); ++i){
        if(pos[i]){
            result |= (1<<i);
        }
    }
    return result;
}

bool check_position(vector<bool> pos){

    for(Order p : orders){
        if(p.a < pos.size() && p.b < pos.size() && pos[p.a] && !pos[p.b]){
            swap(pos[p.a], pos[p.b]);
        }
    }


    bool ended = false, startet = false;
    for(int p : pos){
        if(!startet && !ended && p)
            startet = true;
        if(startet && !p)
            ended = true;
        if(ended && p)
            return false;
    }
    return true;
}

void print_all_posibilities(){
    for(int i = 0; i < posibilities.size(); ++i){
        cout<<i<<":\n";
        for(auto p : posibilities[i]){
            for(auto pp : p){
                cout<<pp<<" ";
            }
            cout<<" : "<<check_position(p)<<"\n";
        }
    }
}

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

    cin>>n>>m;
    for(int i = 0, a, b; i < m; ++i) {
        cin>>a>>b;
        orders.push_back({a - 1, b - 1});
    }

    generate_posibilities(n);
    //print_all_posibilities();
    for(int i = 1; i <= n; ++i){
        int result = 0;
        for(auto p : posibilities[i]){
            if(check_position(p)){
                result++;
            }
        }
        cout<<result%2<<" ";
    }

    



    return 0;
}