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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int long long
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(ll i=(ll)a;i<=(ll)b;++i)
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
const int mxN = 40, mxM = 1e3+7;
pair<int,int> a[mxM];
int n;

bool policz(vector<bool> v, int i){

    // cout << i << ": ";
    // rep(j,1,n) cout << v[j] << " ";
    // cout << "\n";

    if(!i) return 1;
    if(v[a[i].st] == 1 && v[a[i].nd] == 0) return 0;
    if(v[a[i].st] == v[a[i].nd]) return policz(v, i-1);

    bool odp = 0;
    odp ^= policz(v, i-1);
    swap(v[a[i].st], v[a[i].nd]);
    odp ^= policz(v, i-1);
    return odp;
}

bool res[mxN];

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int m; cin >> n >> m;
    rep(i,1,m) cin >> a[i].st >> a[i].nd;

    vector<bool> v;
    rep(i,0,n) v.pb(0);

    rep(k,1,n){
        rep(i,1,n) v[i] = (i <= k);
        rep(i,1,n-k+1){
            res[k] ^= policz(v, m);
            if(i+k <= n) swap(v[i], v[i+k]);
        }
    }
    rep(i,1,n) cout << res[i] << " ";
    cout << "\n";
}