#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    graph={i+1:dict() for i in range(N)}
    #print(graph)
    for i in range(N-1):
        u,v,w=pin()
        graph[u][v]=w%2
        graph[v][u]=w%2
    #print(graph)

    ans={i+1:0 for i in range(N)}
    seen={i+1:0 for i in range(N)}
    #ans[1]=0 (always)
    stack=[(1,0)]#pos,color
    while (stack!=[]):
        p,c=stack.pop()
        if seen[p]==1:continue

        seen[p]=1
        ans[p]=c
        for k,v in graph[p].items():
            stack.append((k,(c+v)%2))
    #print(ans)
    print(*ans.values(),sep="\n")
resolve() import sys sys input= lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def pin(type=int):return map(type,input().split()) pin type=int type int def tupin(t=int):return tuple(pin(t)) tupin t=int t int def lispin(t=int):return list(pin(t))
#%%code lispin t=int t int def resolve():
    N,=pin()
    graph={i+1:dict() for i in range(N)}
    #print(graph)
    for i in range(N-1):
        u,v,w=pin()
        graph[u][v]=w%2
        graph[v][u]=w%2
    #print(graph)

    ans={i+1:0 for i in range(N)}
    seen={i+1:0 for i in range(N)}
    #ans[1]=0 (always)
    stack=[(1,0)]#pos,color
    while (stack!=[]):
        p,c=stack.pop()
        if seen[p]==1:continue

        seen[p]=1
        ans[p]=c
        for k,v in graph[p].items():
            stack.append((k,(c+v)%2))
    #print(ans)
    print(*ans.values(),sep="\n") resolve N,=pin() N pin() pin i+1:dict() for i in range(N) for i in range(N) i range(N) range N for i in range(N) i+1 i 1 dict() dict graph={i+1:dict() for i in range(N)} graph {i+1:dict() for i in range(N)} for i in range(N-1):
        u,v,w=pin()
        graph[u][v]=w%2
        graph[v][u]=w%2
    #print(graph)

     i range(N-1) range N-1 N 1 u,v,w=pin() u pin() pin v w graph[u][v]=w%2 graph[u][v] [u] graph u v w%2 w 2 graph[v][u]=w%2 graph[v][u] [v] graph v u w%2 w 2 i+1:0 for i in range(N) for i in range(N) i range(N) range N for i in range(N) i+1 i 1 0 ans={i+1:0 for i in range(N)} ans {i+1:0 for i in range(N)} i+1:0 for i in range(N) for i in range(N) i range(N) range N for i in range(N) i+1 i 1 0 seen={i+1:0 for i in range(N)} seen {i+1:0 for i in range(N)} stack=[(1,0)] stack [(1,0)] (1,0) 1 0 while (stack!=[]):
        p,c=stack.pop()
        if seen[p]==1:continue

        seen[p]=1
        ans[p]=c
        for k,v in graph[p].items():
            stack.append((k,(c+v)%2))
    #print(ans)
     stack!=[] stack [] p,c=stack.pop() p stack.pop() stack.pop stack pop c if seen[p]==1:continue

         seen[p]==1 seen[p] seen p 1 seen[p]=1 seen[p] seen p 1 ans[p]=c ans[p] ans p c for k,v in graph[p].items():
            stack.append((k,(c+v)%2))
    #print(ans)
     k v graph[p].items() [p].items [p] graph p items stack.append((k,(c+v)%2)) stack.append stack append (k,(c+v)%2) k (c+v)%2 c+v c v 2 print(*ans.values(),sep="\n") print *ans.values() ans.values() ans.values ans values sep="\n" sep "\n" resolve() resolve def resolve():
    N,=pin()
    graph={i+1:dict() for i in range(N)}
    #print(graph)
    for i in range(N-1):
        u,v,w=pin()
        graph[u][v]=w%2
        graph[v][u]=w%2
    #print(graph)

    ans={i+1:0 for i in range(N)}
    seen={i+1:0 for i in range(N)}
    #ans[1]=0 (always)
    stack=[(1,0)]#pos,color
    while (stack!=[]):
        p,c=stack.pop()
        if seen[p]==1:continue

        seen[p]=1
        ans[p]=c
        for k,v in graph[p].items():
            stack.append((k,(c+v)%2))
    #print(ans)
    print(*ans.values(),sep="\n") def resolve():
    N,=pin()
    graph={i+1:dict() for i in range(N)}
    #print(graph)
    for i in range(N-1):
        u,v,w=pin()
        graph[u][v]=w%2
        graph[v][u]=w%2
    #print(graph)

    ans={i+1:0 for i in range(N)}
    seen={i+1:0 for i in range(N)}
    #ans[1]=0 (always)
    stack=[(1,0)]#pos,color
    while (stack!=[]):
        p,c=stack.pop()
        if seen[p]==1:continue

        seen[p]=1
        ans[p]=c
        for k,v in graph[p].items():
            stack.append((k,(c+v)%2))
    #print(ans)
    print(*ans.values(),sep="\n") resolve def tupin(t=int):return tuple(pin(t)) def tupin(t=int):return tuple(pin(t)) tupin input= lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input def pin(type=int):return map(type,input().split()) def pin(type=int):return map(type,input().split()) pin def lispin(t=int):return list(pin(t))
#%%code def lispin(t=int):return list(pin(t))
#%%code lispin
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    graph={i+1:dict() for i in range(N)}
    #print(graph)
    for i in range(N-1):
        u,v,w=pin()
        graph[u][v]=w%2
        graph[v][u]=w%2
    #print(graph)

    ans={i+1:0 for i in range(N)}
    seen={i+1:0 for i in range(N)}
    #ans[1]=0 (always)
    stack=[(1,0)]#pos,color
    while (stack!=[]):
        p,c=stack.pop()
        if seen[p]==1:continue

        seen[p]=1
        ans[p]=c
        for k,v in graph[p].items():
            stack.append((k,(c+v)%2))
    #print(ans)
    print(*ans.values(),sep="\n")
resolve()
