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
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <set>
#include <cstdlib>
#include <ctime>
#include<chrono>
#include<thread>
#include<iomanip>
#include<fstream>
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

using namespace std;
bool check(long long bitmask) {
    long long tmp = bitmask;
    while (((tmp >> 1) << 1) == tmp) {
        tmp >>= 1;
    }
    return ((tmp + 1) & tmp) == 0;
}

long long doOperations(vector<pair <int, int> >& operations, long long bitmask) {
    for (auto& op : operations) {
            int posA = op.first - 1;
            int posB = op.second - 1;
            int bitA = (bitmask >> posA) & 1;
            int bitB = (bitmask >> posB) & 1;

            if (bitA > bitB) {
                bitmask ^= (1 << posA) | (1 << posB);
            }
        }
        return bitmask;
}
bool generatePermutations(int n, int k, vector<pair <int, int> >& operations) {
    long long bitmask = (1 << k) - 1;
    int ans = 0;
    while(bitmask < (1 << n)) {
        ans += check(doOperations(operations, bitmask));
        ans %= 2;
        long long t = (bitmask | (bitmask - 1)) + 1;
        bitmask = t | ((((t & -t) / (bitmask & -bitmask)) >> 1) - 1);
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair <int, int>> operations(m);
    for(int i = 0; i < m; i++) {
        cin >> operations[i].first >> operations[i].second;
    }
    vector<bool> ans(n + 1);
    for(int k = 1; k <= n; k++) {
        ans[k] = generatePermutations(n, k, operations);
    }
    for(int i = 1; i <= n; i++) {
        cout << ans[i] << " ";
    }
    return 0;
}