from collections import deque
import sys
sys.setrecursionlimit(10**7)
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
def dfs(v,c):
    for new,cost in ad_ls[v]:
        if not done_ls[new]:
            cost_ls[new] = c+cost
            done_ls[new] = 1
            dfs(new,c+cost)

dfs(0,0)

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 import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 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 def dfs(v,c):
    for new,cost in ad_ls[v]:
        if not done_ls[new]:
            cost_ls[new] = c+cost
            done_ls[new] = 1
            dfs(new,c+cost) dfs for new,cost in ad_ls[v]:
        if not done_ls[new]:
            cost_ls[new] = c+cost
            done_ls[new] = 1
            dfs(new,c+cost) new cost ad_ls[v] ad_ls v if not done_ls[new]:
            cost_ls[new] = c+cost
            done_ls[new] = 1
            dfs(new,c+cost) not done_ls[new] done_ls[new] done_ls new cost_ls[new] = c+cost cost_ls[new] cost_ls new c+cost c cost done_ls[new] = 1 done_ls[new] done_ls new 1 dfs(new,c+cost) dfs new c+cost c cost v v c c dfs(0,0) dfs 0 0 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 cost_ls = [0] * n [0] * n cost_ls a,b,w = map(int,input().split()) map(int,input().split()) a b,w = map(int,input().split()) map(int,input().split()) b n = int(input()) int(input()) n ad_ls = [[] for _ in range(n)] [[] for _ in range(n)] ad_ls w = map(int,input().split()) map(int,input().split()) w done_ls = [0] * n [0] * n done_ls def dfs(v,c):
    for new,cost in ad_ls[v]:
        if not done_ls[new]:
            cost_ls[new] = c+cost
            done_ls[new] = 1
            dfs(new,c+cost) def dfs(v,c):
    for new,cost in ad_ls[v]:
        if not done_ls[new]:
            cost_ls[new] = c+cost
            done_ls[new] = 1
            dfs(new,c+cost) dfs color_ls = [0] * n [0] * n color_ls
from collections import deque
import sys
sys.setrecursionlimit(10**7)
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
def dfs(v,c):
    for new,cost in ad_ls[v]:
        if not done_ls[new]:
            cost_ls[new] = c+cost
            done_ls[new] = 1
            dfs(new,c+cost)

dfs(0,0)

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

for color in color_ls:
    print(color)