import sys
sys.setrecursionlimit(1000000)

n = int(input())
t = [[] for _ in range(n)]
color = [None for _ in range(n)]
visited = [False for _ in range(n)]


def dfs(n_num):
    visited[n_num] = True
    for i in t[n_num]:
        if visited[i[0]]:
            continue
        if i[1] % 2 == 0:
            color[i[0]] = color[n_num]
        else:
            color[i[0]] = abs(color[n_num] - 1)
        dfs(i[0])


for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    t[u] += [(v, w)]
    t[v] += [(u, w)]

color[0] = 0
dfs(0)
for i in color:
    print(i) import sys sys sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 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) [] t = [[] for _ in range(n)] t [[] for _ in range(n)] None for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) None color = [None for _ in range(n)] color [None for _ in range(n)] 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)] def dfs(n_num):
    visited[n_num] = True
    for i in t[n_num]:
        if visited[i[0]]:
            continue
        if i[1] % 2 == 0:
            color[i[0]] = color[n_num]
        else:
            color[i[0]] = abs(color[n_num] - 1)
        dfs(i[0]) dfs visited[n_num] = True visited[n_num] visited n_num True for i in t[n_num]:
        if visited[i[0]]:
            continue
        if i[1] % 2 == 0:
            color[i[0]] = color[n_num]
        else:
            color[i[0]] = abs(color[n_num] - 1)
        dfs(i[0]) i t[n_num] t n_num if visited[i[0]]:
            continue
         visited[i[0]] visited i[0] i 0 continue if i[1] % 2 == 0:
            color[i[0]] = color[n_num]
        else:
            color[i[0]] = abs(color[n_num] - 1)
         i[1] % 2 == 0 i[1] % 2 i[1] i 1 2 0 color[i[0]] = color[n_num] color[i[0]] color i[0] i 0 color[n_num] color n_num color[i[0]] = abs(color[n_num] - 1) color[i[0]] color i[0] i 0 abs(color[n_num] - 1) abs color[n_num] - 1 color[n_num] color n_num 1 dfs(i[0]) dfs i[0] i 0 n_num n_num for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    t[u] += [(v, w)]
    t[v] += [(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 -= 1 u 1 v -= 1 v 1 t[u] += [(v, w)] t[u] t u [(v, w)] (v, w) v w t[v] += [(u, w)] t[v] t v [(u, w)] (u, w) u w color[0] = 0 color[0] color 0 0 dfs(0) dfs 0 for i in color:
    print(i) i color print(i) print i def dfs(n_num):
    visited[n_num] = True
    for i in t[n_num]:
        if visited[i[0]]:
            continue
        if i[1] % 2 == 0:
            color[i[0]] = color[n_num]
        else:
            color[i[0]] = abs(color[n_num] - 1)
        dfs(i[0]) def dfs(n_num):
    visited[n_num] = True
    for i in t[n_num]:
        if visited[i[0]]:
            continue
        if i[1] % 2 == 0:
            color[i[0]] = color[n_num]
        else:
            color[i[0]] = abs(color[n_num] - 1)
        dfs(i[0]) dfs color = [None for _ in range(n)] [None for _ in range(n)] color w = map(int, input().split()) map(int, input().split()) w v -= 1 1 v u, v, w = map(int, input().split()) map(int, input().split()) u t = [[] for _ in range(n)] [[] for _ in range(n)] t visited = [False for _ in range(n)] [False for _ in range(n)] visited n = int(input()) int(input()) n u -= 1 1 u v, w = map(int, input().split()) map(int, input().split()) v
import sys
sys.setrecursionlimit(1000000)

n = int(input())
t = [[] for _ in range(n)]
color = [None for _ in range(n)]
visited = [False for _ in range(n)]


def dfs(n_num):
    visited[n_num] = True
    for i in t[n_num]:
        if visited[i[0]]:
            continue
        if i[1] % 2 == 0:
            color[i[0]] = color[n_num]
        else:
            color[i[0]] = abs(color[n_num] - 1)
        dfs(i[0])


for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    t[u] += [(v, w)]
    t[v] += [(u, w)]

color[0] = 0
dfs(0)
for i in color:
    print(i)
