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

using namespace std;

#define N 40

//int result[N];
bool result[N];

unsigned long long jedynki[N];

int main() {
    int n, m;

    vector<pair<int, int>> v;

    scanf("%d %d", &n, &m);

    jedynki[n] = 1;
    for (int i = n - 1; i >= 0; i--) {
        jedynki[i] = jedynki[i + 1] << 1;
    }

    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        v.push_back(make_pair(a, b));
    }

    unsigned long long last = ((unsigned long long) 1) << n;

    for (unsigned long long i = 1; i < last; i++) {
        int b = __builtin_popcountll(i);

        unsigned long long j = i;

        for (auto p : v) {
            if (
                (j & jedynki[p.first])
                && !(j & jedynki[p.second])
            ) {
                j = j ^ jedynki[p.first] ^ jedynki[p.second];
            }
        }

        int bit1 = __builtin_ffsll(j);
        int bit2 = log2(j) + 1;

        //printf("%lld %d %d\n", j, bit1, bit2);

        if (bit2 - bit1 + 1 == b) {
            result[b] = !result[b];
            //result[b]++;
        }
    }


    for (int i = 1; i <= n; i++) {
        printf("%d ", result[i] ? 1 : 0);
        //printf("%d ", result[i] );
    }

    return 0;
}