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=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+1)]
    for _ in range(n-1):
        u,v,w=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) main readline=stdin.readline readline stdin.readline stdin readline n=int(readline()) n int(readline()) int readline() readline [] for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [] G=[[] for _ in range(n+1)] G [[] for _ in range(n+1)] for _ in range(n-1):
        u,v,w=map(int,readline().split())
        G[u].append((v,w))
        G[v].append((u,w))

     _ range(n-1) range n-1 n 1 u,v,w=map(int,readline().split()) u map(int,readline().split()) map int readline().split() ().split () readline split v w G[u].append((v,w)) [u].append [u] G u append (v,w) v w G[v].append((u,w)) [v].append [v] G v append (u,w) u w d=[0]*(n+1) d [0]*(n+1) [0] 0 n+1 n 1 flags=[False]*(n+1) flags [False]*(n+1) [False] False n+1 n 1 flags[1]=True flags[1] flags 1 True q=deque([1]) q deque([1]) deque [1] 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]

     len(q)>0 len(q) len q 0 now=q.popleft() now q.popleft() q.popleft 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]

     nex G[now] G now if flags[nex[0]]==False:
                flags[nex[0]]=True
                q.append(nex[0])
                d[nex[0]]=d[now]+nex[1]

     flags[nex[0]]==False flags[nex[0]] flags nex[0] nex 0 False flags[nex[0]]=True flags[nex[0]] flags nex[0] nex 0 True q.append(nex[0]) q.append q append nex[0] nex 0 d[nex[0]]=d[now]+nex[1] d[nex[0]] d nex[0] nex 0 d[now]+nex[1] d[now] d now nex[1] nex 1 for i in range(1,n+1):
        if d[i]%2==0:
            print(0)
        else:
            print(1) i range(1,n+1) range 1 n+1 n 1 if d[i]%2==0:
            print(0)
        else:
            print(1) d[i]%2==0 d[i]%2 d[i] d i 2 0 print(0) print 0 print(1) print 1 if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    G=[[] for _ in range(n+1)]
    for _ in range(n-1):
        u,v,w=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) def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    G=[[] for _ in range(n+1)]
    for _ in range(n-1):
        u,v,w=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) 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=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()