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
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator <<(auto& o, pair<auto, auto> p) {return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator <<(auto& o, auto x)->decltype(x.end(), o) {o<<"{"; for(auto v : x) o<<v<<", "; return o<<"}";}
#define debug(X) cout<<"["#X"]"<<X<<endl;
#else
#define debug(X) {}
#endif
#define int long long
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin>>n>>m;
	vector<pair<int, int> > orders(m);
	for(auto& v : orders) cin>>v.first>>v.second;
	int mask = 0;
	vector<int> res(n+1);
	auto get = [&](int pos)
	{
		return (bool)(mask & (1<<pos));
	};
	while(mask != (1<<n))
	{
		int cp = mask;
		for(auto v : orders)
			if(get(v.first-1) == 1 && get(v.second-1) == 0)
			{
				mask -= (1<<(v.first-1));
				mask += (1<<(v.second-1));
			}
		//for(int i=0;i<n;i++) cout<<get(i);
		//cout<<endl;
		int cnt = 0;
		for(int i=0;i<n;i++)
			if(get(i) == 1)
			{
				cnt++;
				if(cnt == __builtin_popcount(mask)) res[__builtin_popcount(mask)]++;
			}
			else cnt = 0;
		mask = cp;
		mask++;
	}
	reverse(res.begin(), res.end()); res.pop_back(); reverse(res.begin(), res.end());
	for(auto v : res) cout<<v%2<<" ";
}