# -*- coding: utf-8 -*-

import sys

sys.setrecursionlimit(20000000)



n = int(eval(input()))

g = [[] for i in range(n)]

c = [-1 for i in range(n)]



for i in range(n - 1):

    u, v, w = list(map(int, input().split()))

    u -= 1

    v -= 1

    w = w % 2

    g[u].append([v, w])

    g[v].append([u, w])





def dfs(p, d):

    if c[p] == -1:

        c[p] = d

        for x, w in g[p]:

            dfs(x, d ^ w)





dfs(0, 0)



for i in range(len(c)):

    print((c[i]))

# -*- coding: utf-8 -*-

n = int(eval(input()))

g = [[] for i in range(n)]

c = [-1 for i in range(n)]



for i in range(n - 1):

    u, v, w = list(map(int, input().split()))

    u -= 1

    v -= 1

    g[u].append([v, w])

    g[v].append([u, w])





q = [0]

while (len(q) > 0):

    v = q.pop()

    for u, w in g[v]:

        if c[u] != -1:

            continue

        q.append(u)

        c[u] = (c[v] + w) % 2



for v in c:

    print(v)

# -*- coding: utf-8 -*-
import sys

sys.setrecursionlimit(20000000)
n = int(eval(input()))
g = [[] for i in range(n)]
c = [-1 for i in range(n)]
for i in range(n - 1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    w = w % 2
    g[u].append([v, w])
    g[v].append([u, w])


def dfs(p, d):
    if c[p] == -1:
        c[p] = d
        for x, w in g[p]:
            dfs(x, d ^ w)


dfs(0, 0)
for i in range(len(c)):
    print((c[i]))

# -*- coding: utf-8 -*-
n = int(eval(input()))
g = [[] for i in range(n)]
c = [-1 for i in range(n)]
for i in range(n - 1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])
q = [0]
while len(q) > 0:
    v = q.pop()
    for u, w in g[v]:
        if c[u] != -1:
            continue
        q.append(u)
        c[u] = (c[v] + w) % 2
for v in c:
    print(v)

-import sys - -sys.setrecursionlimit(20000000) -    w = w % 2 - - -def dfs(p, d): -    if c[p] == -1: -        c[p] = d -        for x, w in g[p]: -            dfs(x, d ^ w) - - -dfs(0, 0) -for i in range(len(c)): -    print((c[i])) +q = [0] +while len(q) > 0: +    v = q.pop() +    for u, w in g[v]: +        if c[u] != -1: +            continue +        q.append(u) +        c[u] = (c[v] + w) % 2 +for v in c: +    print(v)