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

using namespace std;

typedef long long ll;

#define rep(i, j) for (int i = 0; i < (int)(j); i++)

vector<pair<ll, ll>> ops;

int calc(ll v, int idx) {
  if (idx == -1) {
    return 1;
  }

  ll fst = ops[idx].first;
  ll snd = ops[idx].second;
  ll mask = fst | snd;

  if ((v & mask) == fst) {
    return 0;
  }

  if ((v & mask) == snd) {
    return calc(v, idx - 1) ^ calc(v ^ mask, idx - 1);
  }

  return calc(v, idx - 1);
}

void TEST([[maybe_unused]] int testcase_i) {
  int n, m;
  cin >> n >> m;

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    ops.emplace_back(1LL << a, 1LL << b);
  }

  for (int len = 1; len <= n; len++) {
    int ans = 0;
    for (int start = 0; start + len <= n; start++) {
      ll init = 0;
      rep(j, len) {
        init ^= (1LL << (start + j));
      }
      ans ^= calc(init, m - 1);
    }
    cout << ans << " ";
  }
}

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

  cout << setprecision(20) << fixed;

  // srand(time(NULL));

  int t = 1;
  // cin >> t;
  rep(i, t) {
    TEST(i);
  }

  return 0;
}