from collections import deque
n = int(input())
ad_ls = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,w = map(int,input().split())
    ad_ls[a-1].append([b-1,w])
    ad_ls[b-1].append([a-1,w])

cost_ls = [0] * n
done_ls = [0] * n
done_ls[0] = 1
q = deque()
q.append(0)

while q:
    now = q.pop()
    for new in ad_ls[now]:
        nex,cost = new[0],new[1]
        if not done_ls[nex]:
            cost_ls[nex] = cost + cost_ls[now]
            done_ls[nex] = 1
            q.append(nex)

color_ls = [0] * n
for i in range(n):
    color_ls[i] = cost_ls[i] % 2

for color in color_ls:
    print(color)
 from collections import deque 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) [] ad_ls = [[] for _ in range(n)] ad_ls [[] for _ in range(n)] for _ in range(n-1):
    a,b,w = map(int,input().split())
    ad_ls[a-1].append([b-1,w])
    ad_ls[b-1].append([a-1,w]) _ range(n-1) range n-1 n 1 a,b,w = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b w ad_ls[a-1].append([b-1,w]) [a-1].append [a-1] ad_ls a-1 a 1 append [b-1,w] b-1 b 1 w ad_ls[b-1].append([a-1,w]) [b-1].append [b-1] ad_ls b-1 b 1 append [a-1,w] a-1 a 1 w cost_ls = [0] * n cost_ls [0] * n [0] 0 n done_ls = [0] * n done_ls [0] * n [0] 0 n done_ls[0] = 1 done_ls[0] done_ls 0 1 q = deque() q deque() deque q.append(0) q.append q append 0 while q:
    now = q.pop()
    for new in ad_ls[now]:
        nex,cost = new[0],new[1]
        if not done_ls[nex]:
            cost_ls[nex] = cost + cost_ls[now]
            done_ls[nex] = 1
            q.append(nex) q now = q.pop() now q.pop() q.pop q pop for new in ad_ls[now]:
        nex,cost = new[0],new[1]
        if not done_ls[nex]:
            cost_ls[nex] = cost + cost_ls[now]
            done_ls[nex] = 1
            q.append(nex) new ad_ls[now] ad_ls now nex,cost = new[0],new[1] nex new[0] new 0 cost new[1] new 1 if not done_ls[nex]:
            cost_ls[nex] = cost + cost_ls[now]
            done_ls[nex] = 1
            q.append(nex) not done_ls[nex] done_ls[nex] done_ls nex cost_ls[nex] = cost + cost_ls[now] cost_ls[nex] cost_ls nex cost + cost_ls[now] cost cost_ls[now] cost_ls now done_ls[nex] = 1 done_ls[nex] done_ls nex 1 q.append(nex) q.append q append nex color_ls = [0] * n color_ls [0] * n [0] 0 n for i in range(n):
    color_ls[i] = cost_ls[i] % 2 i range(n) range n color_ls[i] = cost_ls[i] % 2 color_ls[i] color_ls i cost_ls[i] % 2 cost_ls[i] cost_ls i 2 for color in color_ls:
    print(color) color color_ls print(color) print color done_ls = [0] * n [0] * n done_ls ad_ls = [[] for _ in range(n)] [[] for _ in range(n)] ad_ls w = map(int,input().split()) map(int,input().split()) w cost_ls = [0] * n [0] * n cost_ls q = deque() deque() q color_ls = [0] * n [0] * n color_ls n = int(input()) int(input()) n b,w = map(int,input().split()) map(int,input().split()) b now = q.pop() q.pop() now a,b,w = map(int,input().split()) map(int,input().split()) a nex,cost = new[0],new[1] new[0] nex cost = new[0],new[1] new[1] cost
from collections import deque
n = int(input())
ad_ls = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,w = map(int,input().split())
    ad_ls[a-1].append([b-1,w])
    ad_ls[b-1].append([a-1,w])

cost_ls = [0] * n
done_ls = [0] * n
done_ls[0] = 1
q = deque()
q.append(0)

while q:
    now = q.pop()
    for new in ad_ls[now]:
        nex,cost = new[0],new[1]
        if not done_ls[nex]:
            cost_ls[nex] = cost + cost_ls[now]
            done_ls[nex] = 1
            q.append(nex)

color_ls = [0] * n
for i in range(n):
    color_ls[i] = cost_ls[i] % 2

for color in color_ls:
    print(color)

