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
#include <cstdio>
#include <cstring>
#include <unordered_map>
#include <vector>

typedef long long int i64;
typedef char byte;

void process(std::unordered_map<i64, byte> &map, i64 a, i64 b) {
  std::vector<i64> to_remove;
  i64 M1 = 1 << a;
  i64 M2 = 1 << b;
  for (auto &kv : map) {
    i64 k = kv.first;
    if ((k & M1) && (~k & M2)) {
      to_remove.push_back(k);
    }
  }
  for (i64 r : to_remove) {
    i64 modified = (r & ~M1) | M2;
    if (map.contains(modified)) {
      map[modified] ^= map[r];
    } else {
      map[modified] = map[r];
    }
    map.erase(r);
  }
}

int index(i64 v) {
  int res = 0;
  while (v) {
    if (v & 1LL) {
      ++res;
    }
    v >>= 1;
  }
  return res - 1;
}

bool coherent(i64 v) {
  while (!(v & 1LL)) {
    v >>= 1;
  }
  while (v & 1LL) {
    v >>= 1;
  }
  return !v;
}

void sum_up(std::unordered_map<i64, byte> data, i64 N) {
  byte *res = new byte[N];
  memset(res, 0, sizeof(byte) * N);

  for (auto &kv : data) {
    i64 k = kv.first;
    if (coherent(k)) {
      int idx = index(k);
      res[idx] ^= kv.second;
    }
  }

  for (int i = 0; i < N; ++i) {
    printf("%c ", res[i] + '0');
  }
  puts("");
}

int main() {
  i64 N, C;
  scanf("%lld%lld", &N, &C);
  i64 max = 1 << N;
  std::unordered_map<i64, byte> map;
  for (i64 i = 1; i < max; ++i) {
    map[i] = 1;
  }
  for (int i = 0; i < C; ++i) {
    i64 a, b;
    scanf("%lld%lld", &a, &b);
    process(map, a - 1, b - 1);
  }

  sum_up(map, N);
  return 0;
}