from collections import deque

N = int(input())

graph = [[] for _ in range(N+1)]
cost = [[] for _ in range(N+1)]
ans = [-1] * (N+1)

for query in range(N-1):
    u, v, w = map(int, input().split())
    graph[u].append(v)
    cost[u].append(w % 2)
    graph[v].append(u)
    cost[v].append(w % 2)
#print('input')

que = deque()

ans[1] = 0
que.append(1)

while que:
    now = que.popleft()
    #print(graph[now])
    for index in range(len(graph[now])):
        nextg = graph[now][index]
        nextc = cost[now][index]
        #print(ans[nextg])
        if ans[nextg] != -1:
            #print('continued')
            continue
        que.append(nextg)

        #print(nextc)
        if nextc == 1:
            ans[nextg] = (ans[now] + 1) % 2
        else:
            ans[nextg] = ans[now]
    #print(que)
    #print(ans)

#print(ans)

for i in range(1, N+1):
    print(ans[i]) from collections import deque N = int(input()) N int(input()) int input() input [] 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 _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [] cost = [[] for _ in range(N+1)] cost [[] for _ in range(N+1)] ans = [-1] * (N+1) ans [-1] * (N+1) [-1] -1 N+1 N 1 for query in range(N-1):
    u, v, w = map(int, input().split())
    graph[u].append(v)
    cost[u].append(w % 2)
    graph[v].append(u)
    cost[v].append(w % 2)
#print('input') query 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].append(v) [u].append [u] graph u append v cost[u].append(w % 2) [u].append [u] cost u append w % 2 w 2 graph[v].append(u) [v].append [v] graph v append u cost[v].append(w % 2) [v].append [v] cost v append w % 2 w 2 que = deque() que deque() deque ans[1] = 0 ans[1] ans 1 0 que.append(1) que.append que append 1 while que:
    now = que.popleft()
    #print(graph[now])
    for index in range(len(graph[now])):
        nextg = graph[now][index]
        nextc = cost[now][index]
        #print(ans[nextg])
        if ans[nextg] != -1:
            #print('continued')
            continue
        que.append(nextg)

        #print(nextc)
        if nextc == 1:
            ans[nextg] = (ans[now] + 1) % 2
        else:
            ans[nextg] = ans[now]
    #print(que)
    #print(ans)

#print(ans) que now = que.popleft() now que.popleft() que.popleft que popleft for index in range(len(graph[now])):
        nextg = graph[now][index]
        nextc = cost[now][index]
        #print(ans[nextg])
        if ans[nextg] != -1:
            #print('continued')
            continue
        que.append(nextg)

        #print(nextc)
        if nextc == 1:
            ans[nextg] = (ans[now] + 1) % 2
        else:
            ans[nextg] = ans[now]
    #print(que)
    #print(ans)

#print(ans) index range(len(graph[now])) range len(graph[now]) len graph[now] graph now nextg = graph[now][index] nextg graph[now][index] [now] graph now index nextc = cost[now][index] nextc cost[now][index] [now] cost now index if ans[nextg] != -1:
            #print('continued')
            continue
         ans[nextg] != -1 ans[nextg] ans nextg -1 continue que.append(nextg) que.append que append nextg if nextc == 1:
            ans[nextg] = (ans[now] + 1) % 2
        else:
            ans[nextg] = ans[now]
    #print(que)
    #print(ans)

#print(ans) nextc == 1 nextc 1 ans[nextg] = (ans[now] + 1) % 2 ans[nextg] ans nextg (ans[now] + 1) % 2 ans[now] + 1 ans[now] ans now 1 2 ans[nextg] = ans[now] ans[nextg] ans nextg ans[now] ans now for i in range(1, N+1):
    print(ans[i]) i range(1, N+1) range 1 N+1 N 1 print(ans[i]) print ans[i] ans i now = que.popleft() que.popleft() now cost = [[] for _ in range(N+1)] [[] for _ in range(N+1)] cost ans = [-1] * (N+1) [-1] * (N+1) ans nextg = graph[now][index] graph[now][index] nextg w = map(int, input().split()) map(int, input().split()) w u, v, w = map(int, input().split()) map(int, input().split()) u graph = [[] for _ in range(N+1)] [[] for _ in range(N+1)] graph que = deque() deque() que nextc = cost[now][index] cost[now][index] nextc N = int(input()) int(input()) N v, w = map(int, input().split()) map(int, input().split()) v
from collections import deque

N = int(input())

graph = [[] for _ in range(N+1)]
cost = [[] for _ in range(N+1)]
ans = [-1] * (N+1)

for query in range(N-1):
    u, v, w = map(int, input().split())
    graph[u].append(v)
    cost[u].append(w % 2)
    graph[v].append(u)
    cost[v].append(w % 2)
#print('input')

que = deque()

ans[1] = 0
que.append(1)

while que:
    now = que.popleft()
    #print(graph[now])
    for index in range(len(graph[now])):
        nextg = graph[now][index]
        nextc = cost[now][index]
        #print(ans[nextg])
        if ans[nextg] != -1:
            #print('continued')
            continue
        que.append(nextg)

        #print(nextc)
        if nextc == 1:
            ans[nextg] = (ans[now] + 1) % 2
        else:
            ans[nextg] = ans[now]
    #print(que)
    #print(ans)

#print(ans)

for i in range(1, N+1):
    print(ans[i])