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
//
// Jan Zachar 14/03/2024
// Desant 3 [B, dz. 4] 
// Brut O(m * 2^n)
#include <iostream>
using namespace std;

#define f first
#define s second

int n, m;
pair<int, int> R[1006];
int out[36]{};

struct {
	void go()
	{
		for (int p = 1; p < (1<<n); p++) {
			int u = p;
			for (int i = 0; i < m; i++) {
				if ((u & 1<<(R[i].f-1)) && !(u & 1<<(R[i].s-1))) {
					u = u ^ (1<<(R[i].f-1));
					u = u | (1<<(R[i].s-1));
				}
	
			}
	
			bool flag = true;
			for (int i = __builtin_ctz(u); i < 32-__builtin_clz(u); i++) {
				if (!(u & (1<<i))) {
					flag = false;
					break;
				}
			}
			if (!flag) continue;
	
			int at = (32-__builtin_clz(u)) - __builtin_ctz(u);
			out[at]++;
		}
	
		for (int i = 1; i <= n; i++) cout << (out[i]%2) << ' ';
		cout << '\n';
	}
} brut1;

int main()
{
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> R[i].f >> R[i].s;
	}

	if (n <= 30) brut1.go();
	else {
		for (;;) {}
	}

	return 0;
}