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
def is_full_substring(to_check, expected_lenght):
    
    index = 0
    for item in to_check:
        if item == '1':
            break
        index += 1
    
    is_full = True
    for j in range(expected_lenght):
        if to_check[index + j] == '0':
            is_full = False
            break
    return is_full

params = input().split()
n = int(params[0])
m = int(params[1])


orders = []

for item in range(m):
    new_order = input().split()
    arg_1 = int(new_order[0])
    arg_2 = int(new_order[1])
    orders.append([arg_1,arg_2])


combos = dict(zip(range(n), [None]*int(n+1)))


for item in range(n+1):
   combos[item] = []

for i in range(1 << n):
        # Convert the current number to a binary string of length n
        binary_str = format(i, '0' + str(n) + 'b')
        ones = binary_str.count('1')
        combos[ones].append(binary_str)
      
del combos[0]   

result = ''

for d in combos:
    how_many_combos = 0
    for i in range(len(combos[d])):
        
        for order in orders:
            
            first = int(order[0] - 1)
            second = int(order[1] - 1)
            
            if combos[d][i][first] == '1' and combos[d][i][second] == '0':
                new_item = list(combos[d][i])
                new_item[first] = '0'
                new_item[second] = '1'
                combos[d][i] = ''.join(new_item)
        if is_full_substring(combos[d][i],d) == True:
            how_many_combos += 1 
    result += ' ' + str(how_many_combos % 2)

print(result[1:])