from sys import stdin

from collections import deque

def main():

    #入力

    readline=stdin.readline

    N=int(readline())

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

    for _ in range(N-1):

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

        u-=1

        v-=1

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

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



    #0からの距離を幅優先探索

    d=[0]*N

    is_searched=[False]*N

    is_searched[0]=True

    que=deque([0])

    while len(que)>=1:

        now=que.popleft()

        for x in g[now]:

            if is_searched[x[0]]==False:

                is_searched[x[0]]=True

                d[x[0]]=d[now]+x[1]

                que.append(x[0])



    

    for x in d:

        if x%2==0:

            print((0))

        else:

            print((1))



if __name__=="__main__":

    main()
from sys import stdin

from collections import deque

def main():

    #入力

    readline=stdin.readline

    n=int(readline())

    G=[[] for _ in range(n+1)]

    for _ in range(n-1):

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

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

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



    d=[0]*(n+1)

    flags=[False]*(n+1)

    flags[1]=True

    q=deque([1])

    while len(q)>0:

        now=q.popleft()

        for nex in G[now]:

            if flags[nex[0]]==False:

                flags[nex[0]]=True

                q.append(nex[0])

                d[nex[0]]=d[now]+nex[1]



    for i in range(1,n+1):

        if d[i]%2==0:

            print((0))

        else:

            print((1))



if __name__=="__main__":

    main()
from sys import stdin
from collections import deque


def main():
    # 入力
    readline = stdin.readline
    N = int(readline())
    g = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = list(map(int, readline().split()))
        u -= 1
        v -= 1
        g[u].append((v, w))
        g[v].append((u, w))
    # 0からの距離を幅優先探索
    d = [0] * N
    is_searched = [False] * N
    is_searched[0] = True
    que = deque([0])
    while len(que) >= 1:
        now = que.popleft()
        for x in g[now]:
            if is_searched[x[0]] == False:
                is_searched[x[0]] = True
                d[x[0]] = d[now] + x[1]
                que.append(x[0])
    for x in d:
        if x % 2 == 0:
            print((0))
        else:
            print((1))


if __name__ == "__main__":
    main()

from sys import stdin
from collections import deque


def main():
    # 入力
    readline = stdin.readline
    n = int(readline())
    G = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v, w = list(map(int, readline().split()))
        G[u].append((v, w))
        G[v].append((u, w))
    d = [0] * (n + 1)
    flags = [False] * (n + 1)
    flags[1] = True
    q = deque([1])
    while len(q) > 0:
        now = q.popleft()
        for nex in G[now]:
            if flags[nex[0]] == False:
                flags[nex[0]] = True
                q.append(nex[0])
                d[nex[0]] = d[now] + nex[1]
    for i in range(1, n + 1):
        if d[i] % 2 == 0:
            print((0))
        else:
            print((1))


if __name__ == "__main__":
    main()

-    N = int(readline()) -    g = [[] for _ in range(N)] -    for _ in range(N - 1): +    n = int(readline()) +    G = [[] for _ in range(n + 1)] +    for _ in range(n - 1): -        u -= 1 -        v -= 1 -        g[u].append((v, w)) -        g[v].append((u, w)) -    # 0からの距離を幅優先探索 -    d = [0] * N -    is_searched = [False] * N -    is_searched[0] = True -    que = deque([0]) -    while len(que) >= 1: -        now = que.popleft() -        for x in g[now]: -            if is_searched[x[0]] == False: -                is_searched[x[0]] = True -                d[x[0]] = d[now] + x[1] -                que.append(x[0]) -    for x in d: -        if x % 2 == 0: +        G[u].append((v, w)) +        G[v].append((u, w)) +    d = [0] * (n + 1) +    flags = [False] * (n + 1) +    flags[1] = True +    q = deque([1]) +    while len(q) > 0: +        now = q.popleft() +        for nex in G[now]: +            if flags[nex[0]] == False: +                flags[nex[0]] = True +                q.append(nex[0]) +                d[nex[0]] = d[now] + nex[1] +    for i in range(1, n + 1): +        if d[i] % 2 == 0: