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
#include <bits/stdc++.h>
#define debug(x) cout<<#x<<" = "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define inf 1e18
#define mod 1e9+7
using namespace std;
using ll = long long;
using ld = long double;
template <typename H, typename T>
ostream& operator<<(ostream& os, pair<H, T> m){return os <<"("<< m.first<<", "<<m.second<<")";}
template <typename H>
ostream& operator<<(ostream& os, vector<H> V){os<<"{";for(int i=0; i<(int)V.size(); i++){if(i)os<<" ";os<<V[i];}os<<"}" << endl;return os;}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int losuj(int a, int b){return rng()%(b-a+1)+a;}

#define rozmiar 1010

int n, m, a[rozmiar], b[rozmiar], pop;bool odp[rozmiar];
vector<bool> zolnierze;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0;i<=n;i++)zolnierze.push_back(0);
    for(long long mask=1;mask<(1<<n);mask++){
        pop=0;
        for(int i=0;i<=n;i++)zolnierze[i]=0;
        int it=0;
        for(long long j=1;j<=mask;j*=2){
            it++;
            if(mask&j){pop++;zolnierze[it]=1;}
            
        }
        for(int i=0;i<m;i++){
            if(zolnierze[a[i]] && !zolnierze[b[i]])swap(zolnierze[a[i]], zolnierze[b[i]]);
        }
        int mn=100, mx=-1;
        for(int i=1;i<=n;i++){
            if(zolnierze[i] && i<mn)mn=i;
            if(zolnierze[i] && i>mx)mx=i;
        }
        //cout << mx << ' ' << mn << " " << zolnierze << '\n';
        if(mx-mn-pop+1==0){odp[pop]=!odp[pop];}//cout << "btbt" << endl;}
        //cout << pop << " pop" << endl;
    }
    for(int i=1;i<=n;i++)cout << odp[i] << " ";
    cout << endl;
    return 0;
}