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
//2024-03-15
//author: Marcin Rolbiecki
#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second

const int maxM = 1002, maxN = 37;

int n, m;
pair<int, int> ruchy[maxM];
int ans[maxN];

int dfs (vector <int> V, int r)
{
	for (int i = r; i <= m; i++)
	{
		if (V[ruchy[i].f] == 0 && V[ruchy[i].s] == 1)
		{
			return 0;
		}
		if (V[ruchy[i].f] == 1 && V[ruchy[i].s] == 0)
		{
			int res = 0;
			res += dfs(V, i+1);
			swap(V[ruchy[i].f], V[ruchy[i].s]);
			res += dfs(V, i+1);
			return res;
		}
	}

	return 1;
}

int main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int a, b;
		cin >> a >> b;
		ruchy[i] = {b, a};
	}
	reverse(ruchy+1, ruchy+1+m);
	
	for (int i = 1; i <= n; i++)
	{
		for (int j = i; j <= n; j++)
		{	
			vector <int> V (n+1, 0);
			for (int k = i; k <= j; k++)
			{
				V[k] = 1;
			}

			ans[j-i+1] += dfs(V, 1);
		}
	}
	
	for (int i = 1; i <= n; i++)
	{
		cout << ans[i] % 2 << ' ';
	}
	
	return 0;
}