from collections import deque

n = int(eval(input()))



ed = [[] for _ in range(n)]



for _ in range(n-1):

    u,v,w = list(map(int, input().split( )))

    ed[u-1].append([v-1,w])

    ed[v-1].append([u-1,w])#こっちも必要



c = [0]*n

done = [0]*n#無向だから

Q = deque()



Q.append(0)

while Q:

    u = Q.popleft()

    for e in ed[u]:

        if not done[e[0]]:

            c[e[0]] = (e[1]&1) ^ c[u]

            Q.append(e[0])

            done[e[0]] = 1



for i in range(n):

    print((c[i]))
n=int(eval(input()))

e=[[] for _ in range(n)]

for _ in range(n-1):

    xi,yi,wi=list(map(int, input().split()))

    xi-=1;yi-=1

    e[yi].append((xi,wi))

    e[xi].append((yi,wi))



c=[0]*n

used=[0]*n



from collections import deque



q=deque()

q.append(0)

while q:

    u=q.popleft()

    for v,w in e[u]:

        if not used[v]:

            c[v]=(c[u]+w)%2

            used[v]=1

            q.append(v)

for i in c:

    print(i)
from collections import deque

n = int(eval(input()))
ed = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = list(map(int, input().split()))
    ed[u - 1].append([v - 1, w])
    ed[v - 1].append([u - 1, w])  # こっちも必要
c = [0] * n
done = [0] * n  # 無向だから
Q = deque()
Q.append(0)
while Q:
    u = Q.popleft()
    for e in ed[u]:
        if not done[e[0]]:
            c[e[0]] = (e[1] & 1) ^ c[u]
            Q.append(e[0])
            done[e[0]] = 1
for i in range(n):
    print((c[i]))

n = int(eval(input()))
e = [[] for _ in range(n)]
for _ in range(n - 1):
    xi, yi, wi = list(map(int, input().split()))
    xi -= 1
    yi -= 1
    e[yi].append((xi, wi))
    e[xi].append((yi, wi))
c = [0] * n
used = [0] * n
from collections import deque

q = deque()
q.append(0)
while q:
    u = q.popleft()
    for v, w in e[u]:
        if not used[v]:
            c[v] = (c[u] + w) % 2
            used[v] = 1
            q.append(v)
for i in c:
    print(i)

+n = int(eval(input())) +e = [[] for _ in range(n)] +for _ in range(n - 1): +    xi, yi, wi = list(map(int, input().split())) +    xi -= 1 +    yi -= 1 +    e[yi].append((xi, wi)) +    e[xi].append((yi, wi)) +c = [0] * n +used = [0] * n -n = int(eval(input())) -ed = [[] for _ in range(n)] -for _ in range(n - 1): -    u, v, w = list(map(int, input().split())) -    ed[u - 1].append([v - 1, w]) -    ed[v - 1].append([u - 1, w])  # こっちも必要 -c = [0] * n -done = [0] * n  # 無向だから -Q = deque() -Q.append(0) -while Q: -    u = Q.popleft() -    for e in ed[u]: -        if not done[e[0]]: -            c[e[0]] = (e[1] & 1) ^ c[u] -            Q.append(e[0]) -            done[e[0]] = 1 -for i in range(n): -    print((c[i])) +q = deque() +q.append(0) +while q: +    u = q.popleft() +    for v, w in e[u]: +        if not used[v]: +            c[v] = (c[u] + w) % 2 +            used[v] = 1 +            q.append(v) +for i in c: +    print(i)