import unittest

import collections


def solve(n, tree):
    cl = [0] * n
    visited = [False]*n
    stack = []
    stack.append((0, 0))
    while stack:
        v, c = stack.pop()
        if visited[v]:
            continue
        cl[v] = c
        visited[v] = True
        for nv, w in tree[v]:
            if visited[nv]:
                continue
            stack.append((nv, (c + w) % 2))

    return '\n'.join([str(c) for c in cl])


def main():
    n = int(input())
    tree = [[] for i in range(n)]
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        tree[v-1].append((u-1, w % 2))
        tree[u-1].append((v-1, w % 2))
    result = solve(n, tree)
    print(result)


if __name__ == "__main__":
    main() import unittest unittest import collections collections def solve(n, tree):
    cl = [0] * n
    visited = [False]*n
    stack = []
    stack.append((0, 0))
    while stack:
        v, c = stack.pop()
        if visited[v]:
            continue
        cl[v] = c
        visited[v] = True
        for nv, w in tree[v]:
            if visited[nv]:
                continue
            stack.append((nv, (c + w) % 2))

    return '\n'.join([str(c) for c in cl]) solve cl = [0] * n cl [0] * n [0] 0 n visited = [False]*n visited [False]*n [False] False n stack = [] stack [] stack.append((0, 0)) stack.append stack append (0, 0) 0 0 while stack:
        v, c = stack.pop()
        if visited[v]:
            continue
        cl[v] = c
        visited[v] = True
        for nv, w in tree[v]:
            if visited[nv]:
                continue
            stack.append((nv, (c + w) % 2))

     stack v, c = stack.pop() v stack.pop() stack.pop stack pop c if visited[v]:
            continue
         visited[v] visited v continue cl[v] = c cl[v] cl v c visited[v] = True visited[v] visited v True for nv, w in tree[v]:
            if visited[nv]:
                continue
            stack.append((nv, (c + w) % 2))

     nv w tree[v] tree v if visited[nv]:
                continue
             visited[nv] visited nv continue stack.append((nv, (c + w) % 2)) stack.append stack append (nv, (c + w) % 2) nv (c + w) % 2 c + w c w 2 str(c) for c in cl for c in cl c cl for c in cl str(c) str c return '\n'.join([str(c) for c in cl]) '\n'.join([str(c) for c in cl]) '\n'.join '\n' join [str(c) for c in cl] n n tree tree def main():
    n = int(input())
    tree = [[] for i in range(n)]
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        tree[v-1].append((u-1, w % 2))
        tree[u-1].append((v-1, w % 2))
    result = solve(n, tree)
    print(result) main n = int(input()) n int(input()) int input() input [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] tree = [[] for i in range(n)] tree [[] for i in range(n)] for _ in range(n-1):
        u, v, w = map(int, input().split())
        tree[v-1].append((u-1, w % 2))
        tree[u-1].append((v-1, w % 2))
     _ 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 tree[v-1].append((u-1, w % 2)) [v-1].append [v-1] tree v-1 v 1 append (u-1, w % 2) u-1 u 1 w % 2 w 2 tree[u-1].append((v-1, w % 2)) [u-1].append [u-1] tree u-1 u 1 append (v-1, w % 2) v-1 v 1 w % 2 w 2 result = solve(n, tree) result solve(n, tree) solve n tree print(result) print result if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    tree = [[] for i in range(n)]
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        tree[v-1].append((u-1, w % 2))
        tree[u-1].append((v-1, w % 2))
    result = solve(n, tree)
    print(result) def main():
    n = int(input())
    tree = [[] for i in range(n)]
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        tree[v-1].append((u-1, w % 2))
        tree[u-1].append((v-1, w % 2))
    result = solve(n, tree)
    print(result) main def solve(n, tree):
    cl = [0] * n
    visited = [False]*n
    stack = []
    stack.append((0, 0))
    while stack:
        v, c = stack.pop()
        if visited[v]:
            continue
        cl[v] = c
        visited[v] = True
        for nv, w in tree[v]:
            if visited[nv]:
                continue
            stack.append((nv, (c + w) % 2))

    return '\n'.join([str(c) for c in cl]) def solve(n, tree):
    cl = [0] * n
    visited = [False]*n
    stack = []
    stack.append((0, 0))
    while stack:
        v, c = stack.pop()
        if visited[v]:
            continue
        cl[v] = c
        visited[v] = True
        for nv, w in tree[v]:
            if visited[nv]:
                continue
            stack.append((nv, (c + w) % 2))

    return '\n'.join([str(c) for c in cl]) solve
import unittest

import collections


def solve(n, tree):
    cl = [0] * n
    visited = [False]*n
    stack = []
    stack.append((0, 0))
    while stack:
        v, c = stack.pop()
        if visited[v]:
            continue
        cl[v] = c
        visited[v] = True
        for nv, w in tree[v]:
            if visited[nv]:
                continue
            stack.append((nv, (c + w) % 2))

    return '\n'.join([str(c) for c in cl])


def main():
    n = int(input())
    tree = [[] for i in range(n)]
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        tree[v-1].append((u-1, w % 2))
        tree[u-1].append((v-1, w % 2))
    result = solve(n, tree)
    print(result)


if __name__ == "__main__":
    main()
