#!/usr/bin/env python3

n = int(input())

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

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

check = [0 for _ in range(n)]
color = [-1 for _ in range(n)]
color[0] = 0
check[0] = 1


queue = [0]
while(len(queue) > 0):
    index = queue.pop()
    tree_tmp = tree[index]
    for next_, weight in tree_tmp:
        # print(color)
        if color[next_] == -1:
            if weight % 2 == 0:
                color[next_] = color[index]
            else:
                color[next_] = (color[index]+1) % 2
            queue.append(next_)


[print(i) for i in color] 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) [] tree = [[] for _ in range(n)] tree [[] for _ in range(n)] for i in range(n-1):
    u, v, w = list(map(int, input().split()))
    u, v = u-1, v-1

    tree[u].append((v, w))
    tree[v].append((u, w)) i range(n-1) range n-1 n 1 u, v, w = list(map(int, input().split())) u list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split v w u, v = u-1, v-1 u u-1 u 1 v v-1 v 1 tree[u].append((v, w)) [u].append [u] tree u append (v, w) v w tree[v].append((u, w)) [v].append [v] tree v append (u, w) u w 0 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 0 check = [0 for _ in range(n)] check [0 for _ in range(n)] -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 check[0] = 1 check[0] check 0 1 queue = [0] queue [0] 0 while(len(queue) > 0):
    index = queue.pop()
    tree_tmp = tree[index]
    for next_, weight in tree_tmp:
        # print(color)
        if color[next_] == -1:
            if weight % 2 == 0:
                color[next_] = color[index]
            else:
                color[next_] = (color[index]+1) % 2
            queue.append(next_) len(queue) > 0 len(queue) len queue 0 index = queue.pop() index queue.pop() queue.pop queue pop tree_tmp = tree[index] tree_tmp tree[index] tree index for next_, weight in tree_tmp:
        # print(color)
        if color[next_] == -1:
            if weight % 2 == 0:
                color[next_] = color[index]
            else:
                color[next_] = (color[index]+1) % 2
            queue.append(next_) next_ weight tree_tmp if color[next_] == -1:
            if weight % 2 == 0:
                color[next_] = color[index]
            else:
                color[next_] = (color[index]+1) % 2
            queue.append(next_) color[next_] == -1 color[next_] color next_ -1 if weight % 2 == 0:
                color[next_] = color[index]
            else:
                color[next_] = (color[index]+1) % 2
             weight % 2 == 0 weight % 2 weight 2 0 color[next_] = color[index] color[next_] color next_ color[index] color index color[next_] = (color[index]+1) % 2 color[next_] color next_ (color[index]+1) % 2 color[index]+1 color[index] color index 1 2 queue.append(next_) queue.append queue append next_ print(i) for i in color for i in color i color for i in color print(i) print i [print(i) for i in color] tree_tmp = tree[index] tree[index] tree_tmp tree = [[] for _ in range(n)] [[] for _ in range(n)] tree u, v, w = list(map(int, input().split())) list(map(int, input().split())) u check = [0 for _ in range(n)] [0 for _ in range(n)] check index = queue.pop() queue.pop() index n = int(input()) int(input()) n v = u-1, v-1 v-1 v queue = [0] [0] queue v, w = list(map(int, input().split())) list(map(int, input().split())) v u, v = u-1, v-1 u-1 u w = list(map(int, input().split())) list(map(int, input().split())) w color = [-1 for _ in range(n)] [-1 for _ in range(n)] color
#!/usr/bin/env python3

n = int(input())

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

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

check = [0 for _ in range(n)]
color = [-1 for _ in range(n)]
color[0] = 0
check[0] = 1


queue = [0]
while(len(queue) > 0):
    index = queue.pop()
    tree_tmp = tree[index]
    for next_, weight in tree_tmp:
        # print(color)
        if color[next_] == -1:
            if weight % 2 == 0:
                color[next_] = color[index]
            else:
                color[next_] = (color[index]+1) % 2
            queue.append(next_)


[print(i) for i in color]
