import sys
sys.setrecursionlimit(500*500)


n = int(input())
nodes = [list(map(int,input().split())) for _ in range(n-1)]
a = [[] for _ in range(n+1)]

for node in nodes:
    a[node[0]].append([node[1],node[2]])
    a[node[1]].append([node[0],node[2]])

depth = [-1] * (n+1)
depth[1] = 0

def dfs(a,s):
    for v in a[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(a,v[0])    
dfs(a,1)
for d in depth[1:]:
    if d % 2 == 0:
        print(0)
    else:
        print(1) import sys sys sys.setrecursionlimit(500*500) sys.setrecursionlimit sys setrecursionlimit 500*500 500 500 n = int(input()) n int(input()) int input() input list(map(int,input().split())) for _ in range(n-1) for _ in range(n-1) _ range(n-1) range n-1 n 1 for _ in range(n-1) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split nodes = [list(map(int,input().split())) for _ in range(n-1)] nodes [list(map(int,input().split())) for _ in range(n-1)] [] for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [] a = [[] for _ in range(n+1)] a [[] for _ in range(n+1)] for node in nodes:
    a[node[0]].append([node[1],node[2]])
    a[node[1]].append([node[0],node[2]]) node nodes a[node[0]].append([node[1],node[2]]) [node[0]].append [node[0]] a node[0] node 0 append [node[1],node[2]] node[1] node 1 node[2] node 2 a[node[1]].append([node[0],node[2]]) [node[1]].append [node[1]] a node[1] node 1 append [node[0],node[2]] node[0] node 0 node[2] node 2 depth = [-1] * (n+1) depth [-1] * (n+1) [-1] -1 n+1 n 1 depth[1] = 0 depth[1] depth 1 0 def dfs(a,s):
    for v in a[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(a,v[0])     dfs for v in a[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(a,v[0])     v a[s] a s if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(a,v[0])     depth[v[0]] == -1 depth[v[0]] depth v[0] v 0 -1 depth[v[0]] = depth[s] + v[1] depth[v[0]] depth v[0] v 0 depth[s] + v[1] depth[s] depth s v[1] v 1 dfs(a,v[0]) dfs a v[0] v 0 a a s s dfs(a,1) dfs a 1 for d in depth[1:]:
    if d % 2 == 0:
        print(0)
    else:
        print(1) d depth[1:] depth 1: 1 if d % 2 == 0:
        print(0)
    else:
        print(1) d % 2 == 0 d % 2 d 2 0 print(0) print 0 print(1) print 1 n = int(input()) int(input()) n def dfs(a,s):
    for v in a[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(a,v[0])     def dfs(a,s):
    for v in a[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(a,v[0])     dfs nodes = [list(map(int,input().split())) for _ in range(n-1)] [list(map(int,input().split())) for _ in range(n-1)] nodes a = [[] for _ in range(n+1)] [[] for _ in range(n+1)] a depth = [-1] * (n+1) [-1] * (n+1) depth
import sys
sys.setrecursionlimit(500*500)


n = int(input())
nodes = [list(map(int,input().split())) for _ in range(n-1)]
a = [[] for _ in range(n+1)]

for node in nodes:
    a[node[0]].append([node[1],node[2]])
    a[node[1]].append([node[0],node[2]])

depth = [-1] * (n+1)
depth[1] = 0

def dfs(a,s):
    for v in a[s]:
        if depth[v[0]] == -1:
            depth[v[0]] = depth[s] + v[1]
            dfs(a,v[0])    
dfs(a,1)
for d in depth[1:]:
    if d % 2 == 0:
        print(0)
    else:
        print(1)
