import sys
sys.setrecursionlimit(2147483647)



n=int(input())

uvw={}
tree=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=list(map(int,input().split()))
    uvw[(u-1,v-1)]=w
    tree[u-1].append(v-1)
    tree[v-1].append(u-1)
    #u<v

result=[-1]*n
#print(tree)
def DEF(x,dis):
    #print("x",x)
    global tree, uvw,result
    for nextNode in tree[x]:
        if result[nextNode]==-1:
            nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))]
            if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis)
result[0]=0
DEF(0,0)

for item in result:
    print(item) import sys sys sys.setrecursionlimit(2147483647) sys.setrecursionlimit sys setrecursionlimit 2147483647 n=int(input()) n int(input()) int input() input uvw={} uvw {} [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] tree=[[] for _ in range(n)] tree [[] for _ in range(n)] for _ in range(n-1):
    u,v,w=list(map(int,input().split()))
    uvw[(u-1,v-1)]=w
    tree[u-1].append(v-1)
    tree[v-1].append(u-1)
    #u<v _ range(n-1) range n-1 n 1 u,v,w=list(map(int,input().split())) u list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split v w uvw[(u-1,v-1)]=w uvw[(u-1,v-1)] uvw (u-1,v-1) u-1 u 1 v-1 v 1 w tree[u-1].append(v-1) [u-1].append [u-1] tree u-1 u 1 append v-1 v 1 tree[v-1].append(u-1) [v-1].append [v-1] tree v-1 v 1 append u-1 u 1 result=[-1]*n result [-1]*n [-1] -1 n def DEF(x,dis):
    #print("x",x)
    global tree, uvw,result
    for nextNode in tree[x]:
        if result[nextNode]==-1:
            nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))]
            if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis) DEF global tree, uvw,result for nextNode in tree[x]:
        if result[nextNode]==-1:
            nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))]
            if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis) nextNode tree[x] tree x if result[nextNode]==-1:
            nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))]
            if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis) result[nextNode]==-1 result[nextNode] result nextNode -1 nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))] nextDis dis+uvw[(min(x,nextNode),max(x,nextNode))] dis uvw[(min(x,nextNode),max(x,nextNode))] uvw (min(x,nextNode),max(x,nextNode)) min(x,nextNode) min x nextNode max(x,nextNode) max x nextNode if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis) (nextDis)%2==0 (nextDis)%2 nextDis 2 0 result[nextNode]=0 result[nextNode] result nextNode 0 DEF(nextNode,nextDis) DEF nextNode nextDis result[nextNode]=1 result[nextNode] result nextNode 1 DEF(nextNode,nextDis) DEF nextNode nextDis x x dis dis result[0]=0 result[0] result 0 0 DEF(0,0) DEF 0 0 for item in result:
    print(item) item result print(item) print item result=[-1]*n [-1]*n result uvw={} {} uvw u,v,w=list(map(int,input().split())) list(map(int,input().split())) u w=list(map(int,input().split())) list(map(int,input().split())) w tree=[[] for _ in range(n)] [[] for _ in range(n)] tree v,w=list(map(int,input().split())) list(map(int,input().split())) v def DEF(x,dis):
    #print("x",x)
    global tree, uvw,result
    for nextNode in tree[x]:
        if result[nextNode]==-1:
            nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))]
            if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis) def DEF(x,dis):
    #print("x",x)
    global tree, uvw,result
    for nextNode in tree[x]:
        if result[nextNode]==-1:
            nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))]
            if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis) DEF n=int(input()) int(input()) n
import sys
sys.setrecursionlimit(2147483647)



n=int(input())

uvw={}
tree=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=list(map(int,input().split()))
    uvw[(u-1,v-1)]=w
    tree[u-1].append(v-1)
    tree[v-1].append(u-1)
    #u<v

result=[-1]*n
#print(tree)
def DEF(x,dis):
    #print("x",x)
    global tree, uvw,result
    for nextNode in tree[x]:
        if result[nextNode]==-1:
            nextDis=dis+uvw[(min(x,nextNode),max(x,nextNode))]
            if (nextDis)%2==0:
                result[nextNode]=0
                DEF(nextNode,nextDis)
            else:
                result[nextNode]=1
                DEF(nextNode,nextDis)
result[0]=0
DEF(0,0)

for item in result:
    print(item)