import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())

adj = [[] for i in range(n)]
for i in range(n - 1):
    u, v, w = map(int, readline().split())
    u -= 1
    v -= 1
    adj[u].append((w, v))
    adj[v].append((w, u))
# print(adj)

visited = [False for _ in range(n)]
dist = [0 for _ in range(n)]
def dfs(x, depth):
    if visited[x]:
        return
    visited[x] = True
    dist[x] = depth
    for y in adj[x]:
        dfs(y[1], depth + y[0])

dfs(0, 0)

# print(dist)
for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1) import sys sys import itertools itertools import time time import math math sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 from collections import defaultdict read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines n = int(readline()) n int(readline()) int readline() readline [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] adj = [[] for i in range(n)] adj [[] for i in range(n)] for i in range(n - 1):
    u, v, w = map(int, readline().split())
    u -= 1
    v -= 1
    adj[u].append((w, v))
    adj[v].append((w, u))
# print(adj) i range(n - 1) range n - 1 n 1 u, v, w = map(int, readline().split()) u map(int, readline().split()) map int readline().split() ().split () readline split v w u -= 1 u 1 v -= 1 v 1 adj[u].append((w, v)) [u].append [u] adj u append (w, v) w v adj[v].append((w, u)) [v].append [v] adj v append (w, u) w u False for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) False visited = [False for _ in range(n)] visited [False for _ in range(n)] 0 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 0 dist = [0 for _ in range(n)] dist [0 for _ in range(n)] def dfs(x, depth):
    if visited[x]:
        return
    visited[x] = True
    dist[x] = depth
    for y in adj[x]:
        dfs(y[1], depth + y[0]) dfs if visited[x]:
        return
     visited[x] visited x return visited[x] = True visited[x] visited x True dist[x] = depth dist[x] dist x depth for y in adj[x]:
        dfs(y[1], depth + y[0]) y adj[x] adj x dfs(y[1], depth + y[0]) dfs y[1] y 1 depth + y[0] depth y[0] y 0 x x depth depth dfs(0, 0) dfs 0 0 for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1) d dist if d % 2 == 0:
        print(0)
    else:
        print(1) d % 2 == 0 d % 2 d 2 0 print(0) print 0 print(1) print 1 u, v, w = map(int, readline().split()) map(int, readline().split()) u read = sys.stdin.buffer.read sys.stdin.buffer.read read w = map(int, readline().split()) map(int, readline().split()) w n = int(readline()) int(readline()) n v -= 1 1 v u -= 1 1 u readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline adj = [[] for i in range(n)] [[] for i in range(n)] adj visited = [False for _ in range(n)] [False for _ in range(n)] visited def dfs(x, depth):
    if visited[x]:
        return
    visited[x] = True
    dist[x] = depth
    for y in adj[x]:
        dfs(y[1], depth + y[0]) def dfs(x, depth):
    if visited[x]:
        return
    visited[x] = True
    dist[x] = depth
    for y in adj[x]:
        dfs(y[1], depth + y[0]) dfs dist = [0 for _ in range(n)] [0 for _ in range(n)] dist readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines v, w = map(int, readline().split()) map(int, readline().split()) v
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())

adj = [[] for i in range(n)]
for i in range(n - 1):
    u, v, w = map(int, readline().split())
    u -= 1
    v -= 1
    adj[u].append((w, v))
    adj[v].append((w, u))
# print(adj)

visited = [False for _ in range(n)]
dist = [0 for _ in range(n)]
def dfs(x, depth):
    if visited[x]:
        return
    visited[x] = True
    dist[x] = depth
    for y in adj[x]:
        dfs(y[1], depth + y[0])

dfs(0, 0)

# print(dist)
for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1)