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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <iostream>
#include <vector>

using namespace std;

const int mx = 1001;
int a[mx], b[mx];
int n, m;
int ans[36];


inline bool getBit(long long num, int i) {
    return (num & (1LL << i)) != 0;
}


inline void setBit(long long& num, int i) {
    num |= (1LL << i);
}

inline void clearBit(long long& num, int i) {
    num &= (~(1LL << i));
}

inline void toggleBit(long long& num, int i) {
    num ^= (1LL << i);
}

int countSetBits(long long num) {
    int counter = 0;
    while (num) {
        counter += num & 1;
        num >>= 1;
    }
    return counter;
}

void printBinary(long long num) {
    for (int i = 63; i >= 0; --i) {
        cout << getBit(num, i);
    }
    cout << std::endl;
}

vector<long long> candidates[2];

int main() {
    ios::sync_with_stdio(false);

    cin >> n >> m;

    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
    }

    for (int i = 0; i < n; ++i) {
        long long actual = 0;

        setBit(actual, i);
        candidates[0].push_back(actual);
        for (int j = i + 1; j < n; ++j) {
            setBit(actual, j);
            candidates[0].push_back(actual);
        }
    }

    int index = 0;
    int last = 1;

    for (int i = m - 1; i >= 0; --i) {
        index = 1 - index;
        last = 1 - index;

        candidates[index].clear();
        candidates[index].reserve(candidates[last].size());

        int x = a[i] - 1;
        int y = b[i] - 1;

        for (int j = 0; j < candidates[last].size(); ++j) {
            bool x_bit = getBit(candidates[last][j], x);
            bool y_bit = getBit(candidates[last][j], y);

            if ((!x_bit) || y_bit) {
                candidates[index].push_back(candidates[last][j]);
            }
            if ((!x_bit) && y_bit) {
                long long actual = candidates[last][j];
                toggleBit(actual, x);
                toggleBit(actual, y);
                candidates[index].push_back(actual);
            }
        }
    }

    for (int i = 0; i < candidates[index].size(); ++i) {
        long long num = candidates[index][i];
        for (int j = 0; j < m; ++j) {
            int x = a[j] - 1;
            int y = b[j] - 1;
            bool x_bit = getBit(num, x);
            bool y_bit = getBit(num, y);
            if (x_bit && (!y_bit)) {
                toggleBit(num, x);
                toggleBit(num, y);
            }
        }
        int num_of_bits = countSetBits(num);
        ans[num_of_bits] = 1 - ans[num_of_bits];
    }

    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << " ";
    }

    return 0;
}