import sys
sys.setrecursionlimit(20000000)

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

def dfs(node, dist):
    for nxt_node, edge_size in G[node]:
        if ans[nxt_node] == -1:
            ans[nxt_node] = ((dist + edge_size) % 2)
            dfs(nxt_node, dist + edge_size)

ans = [-1] * n
dfs(0, 0)
print(*ans, sep='\n') import sys sys sys.setrecursionlimit(20000000) sys.setrecursionlimit sys setrecursionlimit 20000000 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) [] G = [[] for _ in range(n)] G [[] for _ in range(n)] for i in range(n - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append([v - 1, w])
    G[v - 1].append([u - 1, w]) 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 G[u - 1].append([v - 1, w]) [u - 1].append [u - 1] G u - 1 u 1 append [v - 1, w] v - 1 v 1 w G[v - 1].append([u - 1, w]) [v - 1].append [v - 1] G v - 1 v 1 append [u - 1, w] u - 1 u 1 w def dfs(node, dist):
    for nxt_node, edge_size in G[node]:
        if ans[nxt_node] == -1:
            ans[nxt_node] = ((dist + edge_size) % 2)
            dfs(nxt_node, dist + edge_size) dfs for nxt_node, edge_size in G[node]:
        if ans[nxt_node] == -1:
            ans[nxt_node] = ((dist + edge_size) % 2)
            dfs(nxt_node, dist + edge_size) nxt_node edge_size G[node] G node if ans[nxt_node] == -1:
            ans[nxt_node] = ((dist + edge_size) % 2)
            dfs(nxt_node, dist + edge_size) ans[nxt_node] == -1 ans[nxt_node] ans nxt_node -1 ans[nxt_node] = ((dist + edge_size) % 2) ans[nxt_node] ans nxt_node (dist + edge_size) % 2 dist + edge_size dist edge_size 2 dfs(nxt_node, dist + edge_size) dfs nxt_node dist + edge_size dist edge_size node node dist dist ans = [-1] * n ans [-1] * n [-1] -1 n dfs(0, 0) dfs 0 0 print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' w = map(int, input().split()) map(int, input().split()) w u, v, w = map(int, input().split()) map(int, input().split()) u def dfs(node, dist):
    for nxt_node, edge_size in G[node]:
        if ans[nxt_node] == -1:
            ans[nxt_node] = ((dist + edge_size) % 2)
            dfs(nxt_node, dist + edge_size) def dfs(node, dist):
    for nxt_node, edge_size in G[node]:
        if ans[nxt_node] == -1:
            ans[nxt_node] = ((dist + edge_size) % 2)
            dfs(nxt_node, dist + edge_size) dfs ans = [-1] * n [-1] * n ans n = int(input()) int(input()) n v, w = map(int, input().split()) map(int, input().split()) v G = [[] for _ in range(n)] [[] for _ in range(n)] G
import sys
sys.setrecursionlimit(20000000)

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

def dfs(node, dist):
    for nxt_node, edge_size in G[node]:
        if ans[nxt_node] == -1:
            ans[nxt_node] = ((dist + edge_size) % 2)
            dfs(nxt_node, dist + edge_size)

ans = [-1] * n
dfs(0, 0)
print(*ans, sep='\n')
