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
#include <bits/stdc++.h>
using namespace std;
#define rep(a, b) for (int a = 0; a < (b); a++)
#define rep1(a, b) for (int a = 1; a <= (b); a++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;

#define LOCAL false

const int MAX_N = 30;
const int MAX_M = 1007;
int n, m;

int ans[MAX_N];

pair<int, int> steps[MAX_M];
void process(int msk) {
    int o = msk;
    int bitcnt = 0;
    rep(bi, 30) bitcnt += !!(msk&(1<<bi));
    rep(i, m) {
        auto [b1, b2] = steps[i];
        b1--; b2--;
        if (msk&(1<<b1) && !(msk&(1<<b2))) {
            msk -= (1<<b1);
            msk += (1<<b2);
        }
    }

    while (!(msk&1)) msk >>= 1;
    if (!(msk&(msk+1))) ans[bitcnt] ^= 1;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (LOCAL) {
        ignore=freopen("io/in", "r", stdin);
        ignore=freopen("io/out", "w", stdout);
    }

    cin >> n >> m;
    rep(i, m) cin >> steps[i].first >> steps[i].second;
    rep1(msk, (1<<n)-1) process(msk);

    rep1(i, n) cout << ans[i] << ' ';
    cout << '\n';

    return 0;
}