from collections import defaultdict

N=int(eval(input()))

E=defaultdict(list)

for _ in range(N-1):

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

    u-=1

    v-=1

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

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

ans=[-1]*N



stack=[0]

ans[0]=0

while stack:

    node=stack.pop()

    for to,w in E[node]:

        if ans[to]!=-1: continue

        ans[to]=ans[node]^(w&1)

        stack.append(to)



for c in ans:

    print(c)
import sys

def main():

    input = sys.stdin.readline

    N = int(eval(input()))

    G = [[] for _ in range(N)]

    for _ in range(N-1):

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

        u,v = u-1,v-1

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

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



    ans = [-1] * N

    ans[0] = 0

    stack = [(0,0)]

    while stack:

        v, w = stack.pop()

        for to, to_w in G[v]:

            if ans[to] >= 0: continue

            ans[to] = 1 if (w + to_w) & 1 else 0

            stack.append((to, w + to_w))

    

    for a in ans: print(a)



if __name__ == '__main__':

    main()
from collections import defaultdict

N = int(eval(input()))
E = defaultdict(list)
for _ in range(N - 1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    E[u].append((v, w))
    E[v].append((u, w))
ans = [-1] * N
stack = [0]
ans[0] = 0
while stack:
    node = stack.pop()
    for to, w in E[node]:
        if ans[to] != -1:
            continue
        ans[to] = ans[node] ^ (w & 1)
        stack.append(to)
for c in ans:
    print(c)

import sys


def main():
    input = sys.stdin.readline
    N = int(eval(input()))
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = list(map(int, input().split()))
        u, v = u - 1, v - 1
        G[u].append((v, w))
        G[v].append((u, w))
    ans = [-1] * N
    ans[0] = 0
    stack = [(0, 0)]
    while stack:
        v, w = stack.pop()
        for to, to_w in G[v]:
            if ans[to] >= 0:
                continue
            ans[to] = 1 if (w + to_w) & 1 else 0
            stack.append((to, w + to_w))
    for a in ans:
        print(a)


if __name__ == "__main__":
    main()

-from collections import defaultdict +import sys -N = int(eval(input())) -E = defaultdict(list) -for _ in range(N - 1): -    u, v, w = list(map(int, input().split())) -    u -= 1 -    v -= 1 -    E[u].append((v, w)) -    E[v].append((u, w)) -ans = [-1] * N -stack = [0] -ans[0] = 0 -while stack: -    node = stack.pop() -    for to, w in E[node]: -        if ans[to] != -1: -            continue -        ans[to] = ans[node] ^ (w & 1) -        stack.append(to) -for c in ans: -    print(c) + +def main(): +    input = sys.stdin.readline +    N = int(eval(input())) +    G = [[] for _ in range(N)] +    for _ in range(N - 1): +        u, v, w = list(map(int, input().split())) +        u, v = u - 1, v - 1 +        G[u].append((v, w)) +        G[v].append((u, w)) +    ans = [-1] * N +    ans[0] = 0 +    stack = [(0, 0)] +    while stack: +        v, w = stack.pop() +        for to, to_w in G[v]: +            if ans[to] >= 0: +                continue +            ans[to] = 1 if (w + to_w) & 1 else 0 +            stack.append((to, w + to_w)) +    for a in ans: +        print(a) + + +if __name__ == "__main__": +    main()