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
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i < b;++i)
#define f first
#define s second
#define mp make_pair
#define pb emplace_back
using namespace std;
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    vector<pair<int,int>> V;
    vector<int> pot,wyn(40,0);
    int n,m;
    cin>>n >>m;
    FOR(i,0,m){
        int x,y;
        cin>>x >>y;
        V.pb(mp(x,y));
    }
    pot.pb(1);
    FOR(i,1,30){pot.pb(pot[i - 1] * 2);}
    FOR(i,1,(1 << (n))){
        int x = i;
        FOR(j,0,m){
            if((pot[V[j].f - 1] & x) != 0 && (pot[V[j].s - 1] & x) == 0){
                x-=pot[V[j].f - 1];
                x+=pot[V[j].s - 1];
            }
        }
        int suma = 0,poc = -1,k = __builtin_popcount(x);
        bool B = false;
        FOR(j,0,n){
            if(pot[j] & x){
                ++suma;
            }
            if((pot[j] & x) == 0 && suma != k && suma != 0){
                B = true;
            }
        }
        if(!B){
            ++wyn[k];
        }
    }
    FOR(i,1,n + 1){
        cout<<wyn[i] % 2 <<" ";
    }
}