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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <cassert>
#include <iostream>
#include <istream>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <cstdlib>
#include <memory>
#include <ctime>
#include <bitset>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <ranges>

using namespace std;

class Des2024
{
	int n, m;
	vector<pair<int, int>> input;
	int res = 0;

public:

	// Function to generate all combinations of vectors
	void generateCombinations(std::vector<std::vector<bool>>& result, std::vector<bool>& current, int index, int k) {
		if (k == 0) {
			result.push_back(current); // Add the current combination to the result
			return;
		}

		if (index >= current.size()) {
			return; // Return if the index is out of bounds
		}

		// Case 1: Include the current index
		current[index] = true;
		generateCombinations(result, current, index + 1, k - 1);

		// Case 2: Exclude the current index
		current[index] = false;
		generateCombinations(result, current, index + 1, k);
	}

	// Function to generate all combinations of vectors of size n with exactly k true values
	std::vector<std::vector<bool>> generateAllCombinations(int n, int k) {
		std::vector<std::vector<bool>> result;
		std::vector<bool> current(n, false); // Initialize vector with all false values
		generateCombinations(result, current, 0, k);
		return result;
	}

	vector<bool> applyChangesTo(vector<bool>& vec) {

		vector<bool> copiedVector(vec.begin(), vec.end());
		for (int i = 0; i < m; i++) {
			int a = input[i].first;
			int b = input[i].second;
			if (copiedVector[a-1] && !copiedVector[b-1]) {
				copiedVector[a - 1] = false;
				copiedVector[b - 1] = true;
			}
		}
		return copiedVector;
	}

	bool isFine(vector<bool>& vec) {
		bool falseAfterTrue = false;
		for (int i = 0; i < vec.size(); i++) {
			if (falseAfterTrue && vec[i]) {
				return false;
			}
			if (i > 0 && vec[i-1] && !vec[i]) {
				falseAfterTrue = true;
			}
		}
		return true;
	}

	void virtual Solve()
	{
		cin >> n >> m;
		
		//READ:
		for (int i = 0; i < m; i++) {
			int a, b;
			cin >> a >> b;
			input.push_back(make_pair(a, b));
		}

		vector<int> results = vector<int>(n, 0);

		for (int k = 1; k <= n; k++) {

			int resk = 0;
			vector<vector<bool>> combinations = generateAllCombinations(n, k);

			for (int j = 0; j < combinations.size(); j++) {
				vector<bool> vec = combinations[j];
				vector<bool> newVec = applyChangesTo(vec);
				if (isFine(newVec)) {
					resk++;
					resk = resk % 2;
				}
			}

			results[k - 1] = resk;
		}

		for (int i = 0; i < n; i++) {
			if (i > 0) {
				cout << " ";
			}
			cout << results[i];
		}


	}
};

int main()
{
	Des2024* p = new Des2024();
	p->Solve();
	delete p;
	return 0;
}