import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
uvw = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    uvw[u].append([v, w])
    uvw[v].append([u, w])
color = [-1 for _ in range(n)]
color[0] = 0
def dfs(before_pos, pos, w):
    color[pos] = w
    for next_pos, next_w in uvw[pos]:
        if next_pos == before_pos:
            continue
        dfs(pos, next_pos, (w + next_w) % 2)
    
dfs(-1, 0, 0)
for c in color:
    print(c) import sys sys sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 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) [] uvw = [[] for _ in range(n)] uvw [[] for _ in range(n)] for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    uvw[u].append([v, w])
    uvw[v].append([u, w]) _ 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 -= 1 u 1 v -= 1 v 1 uvw[u].append([v, w]) [u].append [u] uvw u append [v, w] v w uvw[v].append([u, w]) [v].append [v] uvw v append [u, w] u w -1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) -1 color = [-1 for _ in range(n)] color [-1 for _ in range(n)] color[0] = 0 color[0] color 0 0 def dfs(before_pos, pos, w):
    color[pos] = w
    for next_pos, next_w in uvw[pos]:
        if next_pos == before_pos:
            continue
        dfs(pos, next_pos, (w + next_w) % 2)
     dfs color[pos] = w color[pos] color pos w for next_pos, next_w in uvw[pos]:
        if next_pos == before_pos:
            continue
        dfs(pos, next_pos, (w + next_w) % 2)
     next_pos next_w uvw[pos] uvw pos if next_pos == before_pos:
            continue
         next_pos == before_pos next_pos before_pos continue dfs(pos, next_pos, (w + next_w) % 2) dfs pos next_pos (w + next_w) % 2 w + next_w w next_w 2 before_pos before_pos pos pos w w dfs(-1, 0, 0) dfs -1 0 0 for c in color:
    print(c) c color print(c) print c n = int(input()) int(input()) n color = [-1 for _ in range(n)] [-1 for _ in range(n)] color def dfs(before_pos, pos, w):
    color[pos] = w
    for next_pos, next_w in uvw[pos]:
        if next_pos == before_pos:
            continue
        dfs(pos, next_pos, (w + next_w) % 2)
     def dfs(before_pos, pos, w):
    color[pos] = w
    for next_pos, next_w in uvw[pos]:
        if next_pos == before_pos:
            continue
        dfs(pos, next_pos, (w + next_w) % 2)
     dfs w = map(int, input().split()) map(int, input().split()) w v, w = map(int, input().split()) map(int, input().split()) v uvw = [[] for _ in range(n)] [[] for _ in range(n)] uvw u -= 1 1 u u, v, w = map(int, input().split()) map(int, input().split()) u v -= 1 1 v
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
uvw = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    uvw[u].append([v, w])
    uvw[v].append([u, w])
color = [-1 for _ in range(n)]
color[0] = 0
def dfs(before_pos, pos, w):
    color[pos] = w
    for next_pos, next_w in uvw[pos]:
        if next_pos == before_pos:
            continue
        dfs(pos, next_pos, (w + next_w) % 2)
    
dfs(-1, 0, 0)
for c in color:
    print(c)