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
line1 = input()
line1 = list(map(int, line1.split(" ")))
n, m = line1

instructions = []
for _ in range(m):
    line2 = input()
    line2 = list(map(int, line2.split(" ")))
    instructions.append(line2)

ans = []
for i in range(1, n + 1):
    seen = set()

    for sp in range(0, n - i + 1):
        state = [0] * n
        state[sp:sp + i] = [1] * i

        cur_states = [state]

        for inst in reversed(instructions):
            a = inst[0] - 1
            b = inst[1] - 1
            new_states = []
            for ii in range(len(cur_states)):
                cs = cur_states[ii]
                if not (cs[a] and not cs[b]):
                    new_states.append(cs)

                if cs[b] and not cs[a]:
                    ns = cs.copy()
                    ns[a], ns[b] = ns[b], ns[a]
                    new_states.append(ns)
            cur_states = new_states

        cur_states = [tuple(s) for s in cur_states]
        seen = seen.union(cur_states)
    ans.append(str(len(seen) % 2))
print(" ".join(ans))