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
#include <bits/stdc++.h>
#ifdef dbg
#define D(...) fprintf(stderr, __VA_ARGS__)
#define DD(...) D("[Debug] "#__VA_ARGS__ " = "), \
              debug_helper::debug(__VA_ARGS__), D("\n")
#include "C:\Users\wsyear\Desktop\OI\templates\debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template<class T> void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T> void chkmx(T &x, T y) { if (y > x) x = y; }

using namespace std;

const int maxn = 1010;

int n, m, ans[maxn], vec[maxn], c0[maxn], c1[maxn];
pii a[maxn];

void solve() {
  rep (i, 1, n) c0[i] = c0[i - 1] + (vec[i] == 0);
  rep (i, 1, n) c1[i] = c1[i - 1] + (vec[i] == 1);
  rep (l, 1, n) rep (r, l, n) {
    int s0 = c0[r] - c0[l - 1];
    if (s0 > 0) continue;
    if (c1[l - 1] > 0) continue;
    if (c1[n] - c1[r] > 0) continue;
    ans[r - l + 1] ^= 1;
  }
}

void dfs(int dep) {
  if (dep == m + 1) return solve();
  if (vec[a[dep].fi] == -1 && vec[a[dep].se] == -1) {
    vec[a[dep].fi] = vec[a[dep].se] = 0;
    dfs(dep + 1);
    vec[a[dep].fi] = vec[a[dep].se] = 1;
    dfs(dep + 1);
    vec[a[dep].fi] = vec[a[dep].se] = -1;
  } else if (vec[a[dep].fi] != -1 && vec[a[dep].se] != -1) {
    bool flag = vec[a[dep].fi] > vec[a[dep].se];
    if (flag) swap(vec[a[dep].fi], vec[a[dep].se]);
    dfs(dep + 1);
    if (flag) swap(vec[a[dep].fi], vec[a[dep].se]);
  } else if (vec[a[dep].fi] != -1) {
    if (vec[a[dep].fi] == 0) {
      dfs(dep + 1);
    } else {
      swap(vec[a[dep].fi], vec[a[dep].se]);
      dfs(dep + 1);
      swap(vec[a[dep].fi], vec[a[dep].se]);
    }
  } else if (vec[a[dep].se] != -1) {
    if (vec[a[dep].se] == 1) {
      dfs(dep + 1);
    } else {
      swap(vec[a[dep].fi], vec[a[dep].se]);
      dfs(dep + 1);
      swap(vec[a[dep].fi], vec[a[dep].se]);
    }
  }
}

int main() {
  cin.tie(nullptr) -> ios::sync_with_stdio(false);
  cin >> n >> m;
  rep (i, 1, m) cin >> a[i].fi >> a[i].se;
  rep (i, 1, n) vec[i] = -1;
  dfs(1);
  rep (i, 1, n) cout << ans[i] << ' ';
}