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
#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long double
#define uLL unsigned long
using namespace std;
const int N=35,M=1e3+5;
int n,m,a[M],b[M],c0[N],c1[N],ans[N];
inline void solve(vector<int>c,int k){
    if(k>=m){
        for(int i=0;i<n;++i)c0[i+1]=c0[i]+(c[i]==0),c1[i+1]=c1[i]+(c[i]==1);
        for(int l=1;l<=n;++l)for(int r=l;r<=n;++r)
            if(!c1[l-1]&&c1[r]==c1[n]&&c0[l-1]==c0[r])ans[r-l]^=1;
    }
    else if(c[a[k]]==-1&&c[b[k]]==-1)
        c[a[k]]=c[b[k]]=0,solve(c,k+1),c[a[k]]=c[b[k]]=1,solve(c,k+1),c[a[k]]=c[b[k]]=-1;
    else if(c[a[k]]==-1)
        if(c[b[k]]==1)solve(c,k+1);
        else swap(c[a[k]],c[b[k]]),solve(c,k+1);
    else if(c[b[k]]==-1)
        if(c[a[k]]==0)solve(c,k+1);
        else swap(c[a[k]],c[b[k]]),solve(c,k+1);
    else if(c[a[k]]>c[b[k]])swap(c[a[k]],c[b[k]]),solve(c,k+1);
    else solve(c,k+1);
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>m;
    for(int i=0;i<m;++i)cin>>a[i]>>b[i],--a[i],--b[i];
    solve(vector<int>(n,-1),0);
    for(int i=0;i<n;++i)cout<<ans[i]<<' ';
    return 0;
}
/*

*/