import collections
n=int(input())
d=[2]*n
w=collections.deque()
for i in range(n-1):
    a,b,c=map(int,input().split())
    if i==0:
        d[a-1]=0
        d[b-1]=c%2
    elif d[a-1]!=2:
        d[b-1]=(d[a-1]+c%2)%2
    elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
    else:
        w.append((a,b,c))

while len(w):
    a,b,c=w.pop()
    if d[a-1]!=2:
        d[b-1]=(d[a-1]+c%2)%2
    elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
    else:
        w.appendleft((a,b,c))
for i in d:
    print(i) import collections collections n=int(input()) n int(input()) int input() input d=[2]*n d [2]*n [2] 2 n w=collections.deque() w collections.deque() collections.deque collections deque for i in range(n-1):
    a,b,c=map(int,input().split())
    if i==0:
        d[a-1]=0
        d[b-1]=c%2
    elif d[a-1]!=2:
        d[b-1]=(d[a-1]+c%2)%2
    elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
    else:
        w.append((a,b,c)) i range(n-1) range n-1 n 1 a,b,c=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c if i==0:
        d[a-1]=0
        d[b-1]=c%2
    elif d[a-1]!=2:
        d[b-1]=(d[a-1]+c%2)%2
    elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
    else:
        w.append((a,b,c)) i==0 i 0 d[a-1]=0 d[a-1] d a-1 a 1 0 d[b-1]=c%2 d[b-1] d b-1 b 1 c%2 c 2 elif d[a-1]!=2:
        d[b-1]=(d[a-1]+c%2)%2
     d[a-1]!=2 d[a-1] d a-1 a 1 2 d[b-1]=(d[a-1]+c%2)%2 d[b-1] d b-1 b 1 (d[a-1]+c%2)%2 d[a-1]+c%2 d[a-1] d a-1 a 1 c%2 c 2 2 elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
     d[b-1]!=2 d[b-1] d b-1 b 1 2 d[a-1]=(d[b-1]+c%2)%2 d[a-1] d a-1 a 1 (d[b-1]+c%2)%2 d[b-1]+c%2 d[b-1] d b-1 b 1 c%2 c 2 2 w.append((a,b,c)) w.append w append (a,b,c) a b c while len(w):
    a,b,c=w.pop()
    if d[a-1]!=2:
        d[b-1]=(d[a-1]+c%2)%2
    elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
    else:
        w.appendleft((a,b,c)) len(w) len w a,b,c=w.pop() a w.pop() w.pop w pop b c if d[a-1]!=2:
        d[b-1]=(d[a-1]+c%2)%2
    elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
    else:
        w.appendleft((a,b,c)) d[a-1]!=2 d[a-1] d a-1 a 1 2 d[b-1]=(d[a-1]+c%2)%2 d[b-1] d b-1 b 1 (d[a-1]+c%2)%2 d[a-1]+c%2 d[a-1] d a-1 a 1 c%2 c 2 2 elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
     d[b-1]!=2 d[b-1] d b-1 b 1 2 d[a-1]=(d[b-1]+c%2)%2 d[a-1] d a-1 a 1 (d[b-1]+c%2)%2 d[b-1]+c%2 d[b-1] d b-1 b 1 c%2 c 2 2 w.appendleft((a,b,c)) w.appendleft w appendleft (a,b,c) a b c for i in d:
    print(i) i d print(i) print i c=w.pop() w.pop() c b,c=map(int,input().split()) map(int,input().split()) b d=[2]*n [2]*n d b,c=w.pop() w.pop() b a,b,c=map(int,input().split()) map(int,input().split()) a n=int(input()) int(input()) n c=map(int,input().split()) map(int,input().split()) c w=collections.deque() collections.deque() w a,b,c=w.pop() w.pop() a
import collections
n=int(input())
d=[2]*n
w=collections.deque()
for i in range(n-1):
    a,b,c=map(int,input().split())
    if i==0:
        d[a-1]=0
        d[b-1]=c%2
    elif d[a-1]!=2:
        d[b-1]=(d[a-1]+c%2)%2
    elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
    else:
        w.append((a,b,c))

while len(w):
    a,b,c=w.pop()
    if d[a-1]!=2:
        d[b-1]=(d[a-1]+c%2)%2
    elif d[b-1]!=2:
        d[a-1]=(d[b-1]+c%2)%2
    else:
        w.appendleft((a,b,c))
for i in d:
    print(i)
