import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

N = int(input())
edge = [[] for _ in range(N)]

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

ans = [-1] * N
queue = deque([0])

#頂点1を0色に塗る
ans[0] = 0

while queue:
    a = queue.popleft()
    for ve in edge[a]:
        if ans[ve[0]] == -1:
            if ve[1] == 0:
                ans[ve[0]] = ans[a]
            else:
                ans[ve[0]] = (ans[a]+1) % 2
            queue.append(ve[0])

for a in ans:
    print(a) import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip from collections import deque 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) [] edge = [[] for _ in range(N)] edge [[] for _ in range(N)] for i in range(N-1):
    u,v,w = map(int, input().split())
    u, v, w = u - 1, v - 1, w % 2
    edge[u].append((v,w))
    edge[v].append((u,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 u, v, w = u - 1, v - 1, w % 2 u u - 1 u 1 v v - 1 v 1 w w % 2 w 2 edge[u].append((v,w)) [u].append [u] edge u append (v,w) v w edge[v].append((u,w)) [v].append [v] edge v append (u,w) u w ans = [-1] * N ans [-1] * N [-1] -1 N queue = deque([0]) queue deque([0]) deque [0] 0 ans[0] = 0 ans[0] ans 0 0 while queue:
    a = queue.popleft()
    for ve in edge[a]:
        if ans[ve[0]] == -1:
            if ve[1] == 0:
                ans[ve[0]] = ans[a]
            else:
                ans[ve[0]] = (ans[a]+1) % 2
            queue.append(ve[0]) queue a = queue.popleft() a queue.popleft() queue.popleft queue popleft for ve in edge[a]:
        if ans[ve[0]] == -1:
            if ve[1] == 0:
                ans[ve[0]] = ans[a]
            else:
                ans[ve[0]] = (ans[a]+1) % 2
            queue.append(ve[0]) ve edge[a] edge a if ans[ve[0]] == -1:
            if ve[1] == 0:
                ans[ve[0]] = ans[a]
            else:
                ans[ve[0]] = (ans[a]+1) % 2
            queue.append(ve[0]) ans[ve[0]] == -1 ans[ve[0]] ans ve[0] ve 0 -1 if ve[1] == 0:
                ans[ve[0]] = ans[a]
            else:
                ans[ve[0]] = (ans[a]+1) % 2
             ve[1] == 0 ve[1] ve 1 0 ans[ve[0]] = ans[a] ans[ve[0]] ans ve[0] ve 0 ans[a] ans a ans[ve[0]] = (ans[a]+1) % 2 ans[ve[0]] ans ve[0] ve 0 (ans[a]+1) % 2 ans[a]+1 ans[a] ans a 1 2 queue.append(ve[0]) queue.append queue append ve[0] ve 0 for a in ans:
    print(a) a ans print(a) print a w = u - 1, v - 1, w % 2 w % 2 w a = queue.popleft() queue.popleft() a v, w = u - 1, v - 1, w % 2 v - 1 v edge = [[] for _ in range(N)] [[] for _ in range(N)] edge v,w = map(int, input().split()) map(int, input().split()) v input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input u,v,w = map(int, input().split()) map(int, input().split()) u w = map(int, input().split()) map(int, input().split()) w queue = deque([0]) deque([0]) queue N = int(input()) int(input()) N u, v, w = u - 1, v - 1, w % 2 u - 1 u ans = [-1] * N [-1] * N ans
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

N = int(input())
edge = [[] for _ in range(N)]

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

ans = [-1] * N
queue = deque([0])

#頂点1を0色に塗る
ans[0] = 0

while queue:
    a = queue.popleft()
    for ve in edge[a]:
        if ans[ve[0]] == -1:
            if ve[1] == 0:
                ans[ve[0]] = ans[a]
            else:
                ans[ve[0]] = (ans[a]+1) % 2
            queue.append(ve[0])

for a in ans:
    print(a)