n = int(input())
edge = [[int(i) for i in input().split()] for j in range(n-1)]
graph = [[] for _ in range(n+1)]
for i in range(n-1):
    u, v, w = edge[i][0], edge[i][1], edge[i][2] % 2
    graph[u].append((v,w))
    graph[v].append((u,w))

color = [-1] * (n+1)
dist = [0] * (n+1)    
stack = [1]
color[1] = 0

while stack:
    x = stack.pop()
    cx = color[x]
    dx = dist[x]
    for y, w in graph[x]:
        if color[y] >= 0:
            continue
        dist[y] = dist[x] + w
        if dist[x] ^ dist[y] == 0:
            color[y] = color[x]
        else:
            color[y] = (color[x] + 1) % 2
        stack.append(y)
print('\n'.join([str(n) for n in color[1:]])) n = int(input()) n int(input()) int input() input [int(i) for i in input().split()] for j in range(n-1) for j in range(n-1) j range(n-1) range n-1 n 1 for j in range(n-1) [int(i) for i in input().split()] edge = [[int(i) for i in input().split()] for j in range(n-1)] edge [[int(i) for i in input().split()] for j 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) [] graph = [[] for _ in range(n+1)] graph [[] for _ in range(n+1)] for i in range(n-1):
    u, v, w = edge[i][0], edge[i][1], edge[i][2] % 2
    graph[u].append((v,w))
    graph[v].append((u,w)) i range(n-1) range n-1 n 1 u, v, w = edge[i][0], edge[i][1], edge[i][2] % 2 u edge[i][0] [i] edge i 0 v edge[i][1] [i] edge i 1 w edge[i][2] % 2 edge[i][2] [i] edge i 2 2 graph[u].append((v,w)) [u].append [u] graph u append (v,w) v w graph[v].append((u,w)) [v].append [v] graph v append (u,w) u w color = [-1] * (n+1) color [-1] * (n+1) [-1] -1 n+1 n 1 dist = [0] * (n+1) dist [0] * (n+1) [0] 0 n+1 n 1 stack = [1] stack [1] 1 color[1] = 0 color[1] color 1 0 while stack:
    x = stack.pop()
    cx = color[x]
    dx = dist[x]
    for y, w in graph[x]:
        if color[y] >= 0:
            continue
        dist[y] = dist[x] + w
        if dist[x] ^ dist[y] == 0:
            color[y] = color[x]
        else:
            color[y] = (color[x] + 1) % 2
        stack.append(y) stack x = stack.pop() x stack.pop() stack.pop stack pop cx = color[x] cx color[x] color x dx = dist[x] dx dist[x] dist x for y, w in graph[x]:
        if color[y] >= 0:
            continue
        dist[y] = dist[x] + w
        if dist[x] ^ dist[y] == 0:
            color[y] = color[x]
        else:
            color[y] = (color[x] + 1) % 2
        stack.append(y) y w graph[x] graph x if color[y] >= 0:
            continue
         color[y] >= 0 color[y] color y 0 continue dist[y] = dist[x] + w dist[y] dist y dist[x] + w dist[x] dist x w if dist[x] ^ dist[y] == 0:
            color[y] = color[x]
        else:
            color[y] = (color[x] + 1) % 2
         dist[x] ^ dist[y] == 0 dist[x] ^ dist[y] dist[x] dist x dist[y] dist y 0 color[y] = color[x] color[y] color y color[x] color x color[y] = (color[x] + 1) % 2 color[y] color y (color[x] + 1) % 2 color[x] + 1 color[x] color x 1 2 stack.append(y) stack.append stack append y str(n) for n in color[1:] for n in color[1:] n color[1:] color 1: 1 for n in color[1:] str(n) str n print('\n'.join([str(n) for n in color[1:]])) print '\n'.join([str(n) for n in color[1:]]) '\n'.join '\n' join [str(n) for n in color[1:]] v, w = edge[i][0], edge[i][1], edge[i][2] % 2 edge[i][1] v dist = [0] * (n+1) [0] * (n+1) dist stack = [1] [1] stack u, v, w = edge[i][0], edge[i][1], edge[i][2] % 2 edge[i][0] u cx = color[x] color[x] cx dx = dist[x] dist[x] dx n = int(input()) int(input()) n x = stack.pop() stack.pop() x graph = [[] for _ in range(n+1)] [[] for _ in range(n+1)] graph w = edge[i][0], edge[i][1], edge[i][2] % 2 edge[i][2] % 2 w color = [-1] * (n+1) [-1] * (n+1) color edge = [[int(i) for i in input().split()] for j in range(n-1)] [[int(i) for i in input().split()] for j in range(n-1)] edge
n = int(input())
edge = [[int(i) for i in input().split()] for j in range(n-1)]
graph = [[] for _ in range(n+1)]
for i in range(n-1):
    u, v, w = edge[i][0], edge[i][1], edge[i][2] % 2
    graph[u].append((v,w))
    graph[v].append((u,w))

color = [-1] * (n+1)
dist = [0] * (n+1)    
stack = [1]
color[1] = 0

while stack:
    x = stack.pop()
    cx = color[x]
    dx = dist[x]
    for y, w in graph[x]:
        if color[y] >= 0:
            continue
        dist[y] = dist[x] + w
        if dist[x] ^ dist[y] == 0:
            color[y] = color[x]
        else:
            color[y] = (color[x] + 1) % 2
        stack.append(y)
print('\n'.join([str(n) for n in color[1:]]))