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
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define nd second
#define st first
#define sz size
#define forr(i, n) for(int i=1;i<=n;i++)
const ll infl=1e18+90;
const int inf=1e9+90;

int tab[40], pot[40];
vector<int> kan[2];
vector<pair<int,int> > wek;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pot[0]=1;
    for(int i=1;i<=35;i++) pot[i]=pot[i-1]*2;
    int n, m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int a, b;
        cin>>a>>b;
        wek.pb({a, b});
    }
    reverse(wek.begin(), wek.end());
    for(int i=0;i<n;i++)
    {
        int wyn=0;
        for(int j=i;j<n;j++)
        {
            wyn+=pot[j];
            kan[0].pb(wyn);
        }
    }
    bool licz=0;
    for(auto [a, b]:wek)
    {
        a--;
        b--;
        //cerr<<"wchodze dla a = "<<a<<" b= "<<b<<"\n";
        int nl=!licz;
        for(auto mas:kan[licz])
        {
            //cerr<<"wchodze dla maski "<<mas<<"\n";
            int x=0, y=0;
            if((mas&pot[a])!=0) x=1;
            if((mas&pot[b])!=0) y=1;
            if(x==y) kan[nl].pb(mas);
            if(y==1&&x==0)
            {
                kan[nl].pb(mas);
                kan[nl].pb(mas-pot[b]+pot[a]);
            }
        }
        kan[licz].clear();
        licz=nl;
    }
    for(auto it:kan[licz])
    {
        int ile=__builtin_popcountll(it);
        tab[ile]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<tab[i]%2<<" ";
    }
    cout<<"\n";
}