import sys
sys.setrecursionlimit(500*500)

graph = []
distance = []

def dfs(G, v, dist = 0):
    #print(v)
    distance[v-1] = dist

    for i in range(0,len(G[v-1]),2):
        #print(i, G[v-1][i])
        if distance[G[v-1][i]-1] != -1:
            continue
        dist += G[v-1][i+1]
        #print(1,1,dist)
        dfs(G, G[v-1][i], dist)
        dist -= G[v-1][i+1]

N = int(input())

for i in range(N):
    graph.append([])
    distance.append(-1)

for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u-1].append(v)
    graph[u-1].append(w)
    graph[v-1].append(u)
    graph[v-1].append(w)


#print(graph)
#print(distance)

dfs(graph, 1)

for i in range(N):
    if distance[i]%2 == 0:
        print(0)
    else:
        print(1)

#print(graph)
#print(distance) import sys sys sys.setrecursionlimit(500*500) sys.setrecursionlimit sys setrecursionlimit 500*500 500 500 graph = [] graph [] distance = [] distance [] def dfs(G, v, dist = 0):
    #print(v)
    distance[v-1] = dist

    for i in range(0,len(G[v-1]),2):
        #print(i, G[v-1][i])
        if distance[G[v-1][i]-1] != -1:
            continue
        dist += G[v-1][i+1]
        #print(1,1,dist)
        dfs(G, G[v-1][i], dist)
        dist -= G[v-1][i+1] dfs distance[v-1] = dist distance[v-1] distance v-1 v 1 dist for i in range(0,len(G[v-1]),2):
        #print(i, G[v-1][i])
        if distance[G[v-1][i]-1] != -1:
            continue
        dist += G[v-1][i+1]
        #print(1,1,dist)
        dfs(G, G[v-1][i], dist)
        dist -= G[v-1][i+1] i range(0,len(G[v-1]),2) range 0 len(G[v-1]) len G[v-1] G v-1 v 1 2 if distance[G[v-1][i]-1] != -1:
            continue
         distance[G[v-1][i]-1] != -1 distance[G[v-1][i]-1] distance G[v-1][i]-1 G[v-1][i] [v-1] G v-1 v 1 i 1 -1 continue dist += G[v-1][i+1] dist G[v-1][i+1] [v-1] G v-1 v 1 i+1 i 1 dfs(G, G[v-1][i], dist) dfs G G[v-1][i] [v-1] G v-1 v 1 i dist dist -= G[v-1][i+1] dist G[v-1][i+1] [v-1] G v-1 v 1 i+1 i 1 G G v v dist = 0 dist 0 N = int(input()) N int(input()) int input() input for i in range(N):
    graph.append([])
    distance.append(-1) i range(N) range N graph.append([]) graph.append graph append [] distance.append(-1) distance.append distance append -1 for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u-1].append(v)
    graph[u-1].append(w)
    graph[v-1].append(u)
    graph[v-1].append(w)


#print(graph)
#print(distance) i range(N-1) range N-1 N 1 u, v, w = map(int, input().split()) u map(int, input().split()) map int input().split() ().split () input split v w graph[u-1].append(v) [u-1].append [u-1] graph u-1 u 1 append v graph[u-1].append(w) [u-1].append [u-1] graph u-1 u 1 append w graph[v-1].append(u) [v-1].append [v-1] graph v-1 v 1 append u graph[v-1].append(w) [v-1].append [v-1] graph v-1 v 1 append w dfs(graph, 1) dfs graph 1 for i in range(N):
    if distance[i]%2 == 0:
        print(0)
    else:
        print(1)

#print(graph)
#print(distance) i range(N) range N if distance[i]%2 == 0:
        print(0)
    else:
        print(1)

#print(graph)
#print(distance) distance[i]%2 == 0 distance[i]%2 distance[i] distance i 2 0 print(0) print 0 print(1) print 1 def dfs(G, v, dist = 0):
    #print(v)
    distance[v-1] = dist

    for i in range(0,len(G[v-1]),2):
        #print(i, G[v-1][i])
        if distance[G[v-1][i]-1] != -1:
            continue
        dist += G[v-1][i+1]
        #print(1,1,dist)
        dfs(G, G[v-1][i], dist)
        dist -= G[v-1][i+1] def dfs(G, v, dist = 0):
    #print(v)
    distance[v-1] = dist

    for i in range(0,len(G[v-1]),2):
        #print(i, G[v-1][i])
        if distance[G[v-1][i]-1] != -1:
            continue
        dist += G[v-1][i+1]
        #print(1,1,dist)
        dfs(G, G[v-1][i], dist)
        dist -= G[v-1][i+1] dfs u, v, w = map(int, input().split()) map(int, input().split()) u w = map(int, input().split()) map(int, input().split()) w graph = [] [] graph distance = [] [] distance v, w = map(int, input().split()) map(int, input().split()) v N = int(input()) int(input()) N
import sys
sys.setrecursionlimit(500*500)

graph = []
distance = []

def dfs(G, v, dist = 0):
    #print(v)
    distance[v-1] = dist

    for i in range(0,len(G[v-1]),2):
        #print(i, G[v-1][i])
        if distance[G[v-1][i]-1] != -1:
            continue
        dist += G[v-1][i+1]
        #print(1,1,dist)
        dfs(G, G[v-1][i], dist)
        dist -= G[v-1][i+1]

N = int(input())

for i in range(N):
    graph.append([])
    distance.append(-1)

for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u-1].append(v)
    graph[u-1].append(w)
    graph[v-1].append(u)
    graph[v-1].append(w)


#print(graph)
#print(distance)

dfs(graph, 1)

for i in range(N):
    if distance[i]%2 == 0:
        print(0)
    else:
        print(1)

#print(graph)
#print(distance)