n=int(input())
edges=[[] for i in range(n)]
import sys

sys.setrecursionlimit(10**7)
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n") n=int(input()) n int(input()) int input() input [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] edges=[[] for i in range(n)] edges [[] for i in range(n)] import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w]) i range(n-1) range n-1 n 1 a,s,w=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split s w edges[a-1].append([s-1,w]) [a-1].append [a-1] edges a-1 a 1 append [s-1,w] s-1 s 1 w edges[s-1].append([a-1,w]) [s-1].append [s-1] edges s-1 s 1 append [a-1,w] a-1 a 1 w colors=[-1]*n colors [-1]*n [-1] -1 n colors[0]=1 colors[0] colors 0 1 def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to) dfs for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to) to cost edges[now] edges now if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to) colors[to]==-1 colors[to] colors to -1 colors[to]=(cost+colors[now])%2 colors[to] colors to (cost+colors[now])%2 cost+colors[now] cost colors[now] colors now 2 dfs(to) dfs to now now dfs(0) dfs 0 print(*colors,sep="\n") print *colors colors sep="\n" sep "\n" s,w=map(int,input().split()) map(int,input().split()) s w=map(int,input().split()) map(int,input().split()) w colors=[-1]*n [-1]*n colors def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to) def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to) dfs n=int(input()) int(input()) n a,s,w=map(int,input().split()) map(int,input().split()) a edges=[[] for i in range(n)] [[] for i in range(n)] edges
n=int(input())
edges=[[] for i in range(n)]
import sys

sys.setrecursionlimit(10**7)
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")
