
icase=0
if icase==0:
    n=int(input())
    g=[[] for i in range(n)]
    for i in range(n-1):
        ui,vi,wi=map(int,input().split())
        wi=wi%2
        g[ui-1].append((vi-1,wi))
        g[vi-1].append((ui-1,wi))
elif icase==1:
    vv,e,r=4,5,0
    g = [[] for _ in range(vv)]
    g[0]=[(1,1),(2,4)]
    g[1]=[(2,2),(3,5)]
    g[2]=[(3,1)]
    n=3
    g=[[(1, 0)], [(0, 0), (2, 1)], [(1, 1)]]
elif icase==2:
    n=5
    g=[[(2, 0)], [(4, 0), (2, 0)], [(1, 0), (0, 0), (3, 0)], [(2, 0)], [(1, 0)]]

from heapq import heappop,heappush

q=[]
heappush(q,(0,0)) 

inf=float("INF")
dist=[inf]*(n)
dist[0]=0
while len(q)>0:
    dd,state = heappop(q)
#    print("dd:",dd,"state:",state,"q:",q)
    for v,dv in g[state]:
#        print("v:",v,"dv:",dv,"g[state]:",g[state],"parent[v]:",parent[v])
        if dist[v]>dist[state]+dv:
            dist[v]=dist[state]+dv
            heappush(q,(dist[v],v))
#            print(" state:",state,"v:",v,"dist[v]",dist[v])

for i in range(n):
    print(dist[i]%2)
 icase=0 icase 0 if icase==0:
    n=int(input())
    g=[[] for i in range(n)]
    for i in range(n-1):
        ui,vi,wi=map(int,input().split())
        wi=wi%2
        g[ui-1].append((vi-1,wi))
        g[vi-1].append((ui-1,wi))
elif icase==1:
    vv,e,r=4,5,0
    g = [[] for _ in range(vv)]
    g[0]=[(1,1),(2,4)]
    g[1]=[(2,2),(3,5)]
    g[2]=[(3,1)]
    n=3
    g=[[(1, 0)], [(0, 0), (2, 1)], [(1, 1)]]
elif icase==2:
    n=5
    g=[[(2, 0)], [(4, 0), (2, 0)], [(1, 0), (0, 0), (3, 0)], [(2, 0)], [(1, 0)]] icase==0 icase 0 n=int(input()) n int(input()) int input() input [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] g=[[] for i in range(n)] g [[] for i in range(n)] for i in range(n-1):
        ui,vi,wi=map(int,input().split())
        wi=wi%2
        g[ui-1].append((vi-1,wi))
        g[vi-1].append((ui-1,wi)) i range(n-1) range n-1 n 1 ui,vi,wi=map(int,input().split()) ui map(int,input().split()) map int input().split() ().split () input split vi wi wi=wi%2 wi wi%2 wi 2 g[ui-1].append((vi-1,wi)) [ui-1].append [ui-1] g ui-1 ui 1 append (vi-1,wi) vi-1 vi 1 wi g[vi-1].append((ui-1,wi)) [vi-1].append [vi-1] g vi-1 vi 1 append (ui-1,wi) ui-1 ui 1 wi elif icase==1:
    vv,e,r=4,5,0
    g = [[] for _ in range(vv)]
    g[0]=[(1,1),(2,4)]
    g[1]=[(2,2),(3,5)]
    g[2]=[(3,1)]
    n=3
    g=[[(1, 0)], [(0, 0), (2, 1)], [(1, 1)]] icase==1 icase 1 vv,e,r=4,5,0 vv 4 e 5 r 0 [] for _ in range(vv) for _ in range(vv) _ range(vv) range vv for _ in range(vv) [] g = [[] for _ in range(vv)] g [[] for _ in range(vv)] g[0]=[(1,1),(2,4)] g[0] g 0 [(1,1),(2,4)] (1,1) 1 1 (2,4) 2 4 g[1]=[(2,2),(3,5)] g[1] g 1 [(2,2),(3,5)] (2,2) 2 2 (3,5) 3 5 g[2]=[(3,1)] g[2] g 2 [(3,1)] (3,1) 3 1 n=3 n 3 g=[[(1, 0)], [(0, 0), (2, 1)], [(1, 1)]] g [[(1, 0)], [(0, 0), (2, 1)], [(1, 1)]] [(1, 0)] (1, 0) 1 0 [(0, 0), (2, 1)] (0, 0) 0 0 (2, 1) 2 1 [(1, 1)] (1, 1) 1 1 elif icase==2:
    n=5
    g=[[(2, 0)], [(4, 0), (2, 0)], [(1, 0), (0, 0), (3, 0)], [(2, 0)], [(1, 0)]] icase==2 icase 2 n=5 n 5 g=[[(2, 0)], [(4, 0), (2, 0)], [(1, 0), (0, 0), (3, 0)], [(2, 0)], [(1, 0)]] g [[(2, 0)], [(4, 0), (2, 0)], [(1, 0), (0, 0), (3, 0)], [(2, 0)], [(1, 0)]] [(2, 0)] (2, 0) 2 0 [(4, 0), (2, 0)] (4, 0) 4 0 (2, 0) 2 0 [(1, 0), (0, 0), (3, 0)] (1, 0) 1 0 (0, 0) 0 0 (3, 0) 3 0 [(2, 0)] (2, 0) 2 0 [(1, 0)] (1, 0) 1 0 from heapq import heappop,heappush q=[] q [] heappush(q,(0,0)) heappush q (0,0) 0 0 inf=float("INF") inf float("INF") float "INF" dist=[inf]*(n) dist [inf]*(n) [inf] inf n dist[0]=0 dist[0] dist 0 0 while len(q)>0:
    dd,state = heappop(q)
#    print("dd:",dd,"state:",state,"q:",q)
    for v,dv in g[state]:
#        print("v:",v,"dv:",dv,"g[state]:",g[state],"parent[v]:",parent[v])
        if dist[v]>dist[state]+dv:
            dist[v]=dist[state]+dv
            heappush(q,(dist[v],v))
#            print(" state:",state,"v:",v,"dist[v]",dist[v]) len(q)>0 len(q) len q 0 dd,state = heappop(q) dd heappop(q) heappop q state for v,dv in g[state]:
#        print("v:",v,"dv:",dv,"g[state]:",g[state],"parent[v]:",parent[v])
        if dist[v]>dist[state]+dv:
            dist[v]=dist[state]+dv
            heappush(q,(dist[v],v))
#            print(" state:",state,"v:",v,"dist[v]",dist[v]) v dv g[state] g state if dist[v]>dist[state]+dv:
            dist[v]=dist[state]+dv
            heappush(q,(dist[v],v))
#            print(" state:",state,"v:",v,"dist[v]",dist[v]) dist[v]>dist[state]+dv dist[v] dist v dist[state]+dv dist[state] dist state dv dist[v]=dist[state]+dv dist[v] dist v dist[state]+dv dist[state] dist state dv heappush(q,(dist[v],v)) heappush q (dist[v],v) dist[v] dist v v for i in range(n):
    print(dist[i]%2) i range(n) range n print(dist[i]%2) print dist[i]%2 dist[i] dist i 2 e,r=4,5,0 5 e q=[] [] q r=4,5,0 0 r n=5 5 n icase=0 0 icase inf=float("INF") float("INF") inf dd,state = heappop(q) heappop(q) dd wi=map(int,input().split()) map(int,input().split()) wi wi=wi%2 wi%2 wi g=[[] for i in range(n)] [[] for i in range(n)] g vi,wi=map(int,input().split()) map(int,input().split()) vi g = [[] for _ in range(vv)] [[] for _ in range(vv)] g ui,vi,wi=map(int,input().split()) map(int,input().split()) ui g=[[(1, 0)], [(0, 0), (2, 1)], [(1, 1)]] [[(1, 0)], [(0, 0), (2, 1)], [(1, 1)]] g n=int(input()) int(input()) n g=[[(2, 0)], [(4, 0), (2, 0)], [(1, 0), (0, 0), (3, 0)], [(2, 0)], [(1, 0)]] [[(2, 0)], [(4, 0), (2, 0)], [(1, 0), (0, 0), (3, 0)], [(2, 0)], [(1, 0)]] g state = heappop(q) heappop(q) state n=3 3 n dist=[inf]*(n) [inf]*(n) dist vv,e,r=4,5,0 4 vv

icase=0
if icase==0:
    n=int(input())
    g=[[] for i in range(n)]
    for i in range(n-1):
        ui,vi,wi=map(int,input().split())
        wi=wi%2
        g[ui-1].append((vi-1,wi))
        g[vi-1].append((ui-1,wi))
elif icase==1:
    vv,e,r=4,5,0
    g = [[] for _ in range(vv)]
    g[0]=[(1,1),(2,4)]
    g[1]=[(2,2),(3,5)]
    g[2]=[(3,1)]
    n=3
    g=[[(1, 0)], [(0, 0), (2, 1)], [(1, 1)]]
elif icase==2:
    n=5
    g=[[(2, 0)], [(4, 0), (2, 0)], [(1, 0), (0, 0), (3, 0)], [(2, 0)], [(1, 0)]]

from heapq import heappop,heappush

q=[]
heappush(q,(0,0)) 

inf=float("INF")
dist=[inf]*(n)
dist[0]=0
while len(q)>0:
    dd,state = heappop(q)
#    print("dd:",dd,"state:",state,"q:",q)
    for v,dv in g[state]:
#        print("v:",v,"dv:",dv,"g[state]:",g[state],"parent[v]:",parent[v])
        if dist[v]>dist[state]+dv:
            dist[v]=dist[state]+dv
            heappush(q,(dist[v],v))
#            print(" state:",state,"v:",v,"dist[v]",dist[v])

for i in range(n):
    print(dist[i]%2)

