n=int(input())
e=[[] for _ in range(n)]
for _ in range(n-1):
    xi,yi,wi=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(input()) n int(input()) int input() input [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] e=[[] for _ in range(n)] e [[] for _ in range(n)] for _ in range(n-1):
    xi,yi,wi=map(int, input().split())
    xi-=1;yi-=1
    e[yi].append((xi,wi))
    e[xi].append((yi,wi)) _ range(n-1) range n-1 n 1 xi,yi,wi=map(int, input().split()) xi map(int, input().split()) map int input().split() ().split () input split yi wi xi-=1 xi 1 yi-=1 yi 1 e[yi].append((xi,wi)) [yi].append [yi] e yi append (xi,wi) xi wi e[xi].append((yi,wi)) [xi].append [xi] e xi append (yi,wi) yi wi c=[0]*n c [0]*n [0] 0 n used=[0]*n used [0]*n [0] 0 n from collections import deque q=deque() q deque() deque q.append(0) q.append 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) q u=q.popleft() u q.popleft() q.popleft q popleft for v,w in e[u]:
        if not used[v]:
            c[v]=(c[u]+w)%2
            used[v]=1
            q.append(v) v w e[u] e u if not used[v]:
            c[v]=(c[u]+w)%2
            used[v]=1
            q.append(v) not used[v] used[v] used v c[v]=(c[u]+w)%2 c[v] c v (c[u]+w)%2 c[u]+w c[u] c u w 2 used[v]=1 used[v] used v 1 q.append(v) q.append q append v for i in c:
    print(i) i c print(i) print i xi,yi,wi=map(int, input().split()) map(int, input().split()) xi c=[0]*n [0]*n c u=q.popleft() q.popleft() u yi,wi=map(int, input().split()) map(int, input().split()) yi q=deque() deque() q n=int(input()) int(input()) n wi=map(int, input().split()) map(int, input().split()) wi used=[0]*n [0]*n used xi-=1 1 xi e=[[] for _ in range(n)] [[] for _ in range(n)] e yi-=1 1 yi
n=int(input())
e=[[] for _ in range(n)]
for _ in range(n-1):
    xi,yi,wi=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)