# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, input().split()))


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]

from heapq import heapify, heappush, heappop
def dijkstra(path, N, start):
    visited = [False] * N
    que = [(0, start)]
    heapify(que)  # 始点aから各頂点への(距離, 頂点ID)
    dist = [-1] * N  # 始点aから各頂点への距離
    dist[start] = 0  # 始点aからaへの距離は0
    while que:
        d, v = heappop(que)  # 始点から最短距離の頂点を(確定ノード)を取り出す
        visited[v] = True  # 確定フラグを立てる
        # 接続先ノードの情報を更新する
        for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))
    return dist
N = z()
# 0 を頂点とする根付き木を考える
path = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = zz()
    path[u-1].append((w, v-1))
    path[v-1].append((w, u-1))
dist = dijkstra(path, N, 0)
# print(dist)
ans = [0] * N
for i, d in enumerate(dist):
    if (d % 2 == 0):
        ans[i] = 0 
    else:
        ans[i] = 1

print(*ans, sep='\n')
             import numpy as np numpy from collections import deque from collections import defaultdict import heapq heapq import collections collections import itertools itertools import bisect bisect def zz():
    return list(map(int, input().split())) zz return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def z():
    return int(input()) z return int(input()) int(input()) int input() input def S():
    return input() S return input() input() input def C(line):
    return [input() for _ in range(line)] C input() for _ in range(line) for _ in range(line) _ range(line) range line for _ in range(line) input() input return [input() for _ in range(line)] [input() for _ in range(line)] line line from heapq import heapify, heappush, heappop def dijkstra(path, N, start):
    visited = [False] * N
    que = [(0, start)]
    heapify(que)  # 始点aから各頂点への(距離, 頂点ID)
    dist = [-1] * N  # 始点aから各頂点への距離
    dist[start] = 0  # 始点aからaへの距離は0
    while que:
        d, v = heappop(que)  # 始点から最短距離の頂点を(確定ノード)を取り出す
        visited[v] = True  # 確定フラグを立てる
        # 接続先ノードの情報を更新する
        for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))
    return dist dijkstra visited = [False] * N visited [False] * N [False] False N que = [(0, start)] que [(0, start)] (0, start) 0 start heapify(que) heapify que dist = [-1] * N dist [-1] * N [-1] -1 N dist[start] = 0 dist[start] dist start 0 while que:
        d, v = heappop(que)  # 始点から最短距離の頂点を(確定ノード)を取り出す
        visited[v] = True  # 確定フラグを立てる
        # 接続先ノードの情報を更新する
        for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))
     que d, v = heappop(que) d heappop(que) heappop que v visited[v] = True visited[v] visited v True for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))
     d to path[v] path v cost = dist[v] + d cost dist[v] + d dist[v] dist v d if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))
     dist[to] < 0 or cost < dist[to] dist[to] < 0 dist[to] dist to 0 cost < dist[to] cost dist[to] dist to dist[to] = cost dist[to] dist to cost if not visited[to]:
                    heappush(que, (cost, to))
     not visited[to] visited[to] visited to heappush(que, (cost, to)) heappush que (cost, to) cost to return dist dist path path N N start start N = z() N z() z [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] path = [[] for _ in range(N)] path [[] for _ in range(N)] for i in range(N-1):
    u, v, w = zz()
    path[u-1].append((w, v-1))
    path[v-1].append((w, u-1)) i range(N-1) range N-1 N 1 u, v, w = zz() u zz() zz v w path[u-1].append((w, v-1)) [u-1].append [u-1] path u-1 u 1 append (w, v-1) w v-1 v 1 path[v-1].append((w, u-1)) [v-1].append [v-1] path v-1 v 1 append (w, u-1) w u-1 u 1 dist = dijkstra(path, N, 0) dist dijkstra(path, N, 0) dijkstra path N 0 ans = [0] * N ans [0] * N [0] 0 N for i, d in enumerate(dist):
    if (d % 2 == 0):
        ans[i] = 0 
    else:
        ans[i] = 1 i d enumerate(dist) enumerate dist if (d % 2 == 0):
        ans[i] = 0 
    else:
        ans[i] = 1 d % 2 == 0 d % 2 d 2 0 ans[i] = 0 ans[i] ans i 0 ans[i] = 1 ans[i] ans i 1 print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' def S():
    return input() def S():
    return input() S def dijkstra(path, N, start):
    visited = [False] * N
    que = [(0, start)]
    heapify(que)  # 始点aから各頂点への(距離, 頂点ID)
    dist = [-1] * N  # 始点aから各頂点への距離
    dist[start] = 0  # 始点aからaへの距離は0
    while que:
        d, v = heappop(que)  # 始点から最短距離の頂点を(確定ノード)を取り出す
        visited[v] = True  # 確定フラグを立てる
        # 接続先ノードの情報を更新する
        for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))
    return dist def dijkstra(path, N, start):
    visited = [False] * N
    que = [(0, start)]
    heapify(que)  # 始点aから各頂点への(距離, 頂点ID)
    dist = [-1] * N  # 始点aから各頂点への距離
    dist[start] = 0  # 始点aからaへの距離は0
    while que:
        d, v = heappop(que)  # 始点から最短距離の頂点を(確定ノード)を取り出す
        visited[v] = True  # 確定フラグを立てる
        # 接続先ノードの情報を更新する
        for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))
    return dist dijkstra def z():
    return int(input()) def z():
    return int(input()) z def C(line):
    return [input() for _ in range(line)] def C(line):
    return [input() for _ in range(line)] C path = [[] for _ in range(N)] [[] for _ in range(N)] path dist = dijkstra(path, N, 0) dijkstra(path, N, 0) dist u, v, w = zz() zz() u ans = [0] * N [0] * N ans N = z() z() N v, w = zz() zz() v def zz():
    return list(map(int, input().split())) def zz():
    return list(map(int, input().split())) zz w = zz() zz() w
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, input().split()))


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]

from heapq import heapify, heappush, heappop
def dijkstra(path, N, start):
    visited = [False] * N
    que = [(0, start)]
    heapify(que)  # 始点aから各頂点への(距離, 頂点ID)
    dist = [-1] * N  # 始点aから各頂点への距離
    dist[start] = 0  # 始点aからaへの距離は0
    while que:
        d, v = heappop(que)  # 始点から最短距離の頂点を(確定ノード)を取り出す
        visited[v] = True  # 確定フラグを立てる
        # 接続先ノードの情報を更新する
        for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))
    return dist
N = z()
# 0 を頂点とする根付き木を考える
path = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = zz()
    path[u-1].append((w, v-1))
    path[v-1].append((w, u-1))
dist = dijkstra(path, N, 0)
# print(dist)
ans = [0] * N
for i, d in enumerate(dist):
    if (d % 2 == 0):
        ans[i] = 0 
    else:
        ans[i] = 1

print(*ans, sep='\n')
            
