import sys

sys.setrecursionlimit(1000000)

num_node = int(input())
relation = [[[], []] for i in range(num_node + 1)]
for i in range(num_node - 1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        relation[u][0].append(v)
        relation[v][0].append(u)
    else:
        relation[u][1].append(v)
        relation[v][1].append(u)
colors = [None] * (num_node + 1)


def dfs(n: int, c: int):
    colors[n] = c
    # 偶数
    for even_idx in relation[n][0]:
        if colors[even_idx] is not None:
            continue
        else:
            dfs(even_idx, colors[n])
    # 奇数
    for odd_idx in relation[n][1]:
        if colors[odd_idx] is not None:
            continue
        else:
            dfs(odd_idx, 1 - colors[n])


if __name__ == '__main__':
    dfs(1, 0)
    for ans in list(map(int, colors[1:])):
        print(ans) import sys sys sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 num_node = int(input()) num_node int(input()) int input() input [[], []] for i in range(num_node + 1) for i in range(num_node + 1) i range(num_node + 1) range num_node + 1 num_node 1 for i in range(num_node + 1) [[], []] [] [] relation = [[[], []] for i in range(num_node + 1)] relation [[[], []] for i in range(num_node + 1)] for i in range(num_node - 1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        relation[u][0].append(v)
        relation[v][0].append(u)
    else:
        relation[u][1].append(v)
        relation[v][1].append(u) i range(num_node - 1) range num_node - 1 num_node 1 u, v, w = map(int, input().split()) u map(int, input().split()) map int input().split() ().split () input split v w if w % 2 == 0:
        relation[u][0].append(v)
        relation[v][0].append(u)
    else:
        relation[u][1].append(v)
        relation[v][1].append(u) w % 2 == 0 w % 2 w 2 0 relation[u][0].append(v) [0].append [0] [u] relation u 0 append v relation[v][0].append(u) [0].append [0] [v] relation v 0 append u relation[u][1].append(v) [1].append [1] [u] relation u 1 append v relation[v][1].append(u) [1].append [1] [v] relation v 1 append u colors = [None] * (num_node + 1) colors [None] * (num_node + 1) [None] None num_node + 1 num_node 1 def dfs(n: int, c: int):
    colors[n] = c
    # 偶数
    for even_idx in relation[n][0]:
        if colors[even_idx] is not None:
            continue
        else:
            dfs(even_idx, colors[n])
    # 奇数
    for odd_idx in relation[n][1]:
        if colors[odd_idx] is not None:
            continue
        else:
            dfs(odd_idx, 1 - colors[n]) dfs colors[n] = c colors[n] colors n c for even_idx in relation[n][0]:
        if colors[even_idx] is not None:
            continue
        else:
            dfs(even_idx, colors[n])
    # 奇数
     even_idx relation[n][0] [n] relation n 0 if colors[even_idx] is not None:
            continue
        else:
            dfs(even_idx, colors[n])
    # 奇数
     colors[even_idx] is not None colors[even_idx] colors even_idx None continue dfs(even_idx, colors[n]) dfs even_idx colors[n] colors n for odd_idx in relation[n][1]:
        if colors[odd_idx] is not None:
            continue
        else:
            dfs(odd_idx, 1 - colors[n]) odd_idx relation[n][1] [n] relation n 1 if colors[odd_idx] is not None:
            continue
        else:
            dfs(odd_idx, 1 - colors[n]) colors[odd_idx] is not None colors[odd_idx] colors odd_idx None continue dfs(odd_idx, 1 - colors[n]) dfs odd_idx 1 - colors[n] 1 colors[n] colors n n: int n c: int c if __name__ == '__main__':
    dfs(1, 0)
    for ans in list(map(int, colors[1:])):
        print(ans) __name__ == '__main__' __name__ '__main__' dfs(1, 0) dfs 1 0 for ans in list(map(int, colors[1:])):
        print(ans) ans list(map(int, colors[1:])) list map(int, colors[1:]) map int colors[1:] colors 1: 1 print(ans) print ans def dfs(n: int, c: int):
    colors[n] = c
    # 偶数
    for even_idx in relation[n][0]:
        if colors[even_idx] is not None:
            continue
        else:
            dfs(even_idx, colors[n])
    # 奇数
    for odd_idx in relation[n][1]:
        if colors[odd_idx] is not None:
            continue
        else:
            dfs(odd_idx, 1 - colors[n]) def dfs(n: int, c: int):
    colors[n] = c
    # 偶数
    for even_idx in relation[n][0]:
        if colors[even_idx] is not None:
            continue
        else:
            dfs(even_idx, colors[n])
    # 奇数
    for odd_idx in relation[n][1]:
        if colors[odd_idx] is not None:
            continue
        else:
            dfs(odd_idx, 1 - colors[n]) dfs w = map(int, input().split()) map(int, input().split()) w num_node = int(input()) int(input()) num_node u, v, w = map(int, input().split()) map(int, input().split()) u v, w = map(int, input().split()) map(int, input().split()) v relation = [[[], []] for i in range(num_node + 1)] [[[], []] for i in range(num_node + 1)] relation colors = [None] * (num_node + 1) [None] * (num_node + 1) colors
import sys

sys.setrecursionlimit(1000000)

num_node = int(input())
relation = [[[], []] for i in range(num_node + 1)]
for i in range(num_node - 1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        relation[u][0].append(v)
        relation[v][0].append(u)
    else:
        relation[u][1].append(v)
        relation[v][1].append(u)
colors = [None] * (num_node + 1)


def dfs(n: int, c: int):
    colors[n] = c
    # 偶数
    for even_idx in relation[n][0]:
        if colors[even_idx] is not None:
            continue
        else:
            dfs(even_idx, colors[n])
    # 奇数
    for odd_idx in relation[n][1]:
        if colors[odd_idx] is not None:
            continue
        else:
            dfs(odd_idx, 1 - colors[n])


if __name__ == '__main__':
    dfs(1, 0)
    for ans in list(map(int, colors[1:])):
        print(ans)
