import sys
INFTY=sys.maxsize
sys.setrecursionlimit(100000)

def readinput():
    n=int(input())
    nList=[]
    for _ in range(n+1):
        nList.append([])
    for _ in range(1,n):
        u,v,w=map(int,input().split())
        nList[u].append((v,w))
        nList[v].append((u,w))

    return n,nList

WHITE=0
GRAY=1
BLACK=2
status=[]
color=[]

def dfs(s,nList):
    for u,w in nList[s]:
        if status[u]==WHITE:
            if w%2==0:
                color[u]=color[s]
            else:
                color[u]=(color[s]+1)%2
            status[u]=GRAY
            dfs(u,nList)
    status[s]=BLACK

def main(n,nList):
    global status
    global color

    status=[WHITE]*(n+1)
    color=[WHITE]*(n+1)
    dfs(1,nList)

    for i in range(1,n+1):
        print(color[i])
    

if __name__=='__main__':
    n,nList=readinput()
    main(n,nList)
    #print(ans) import sys sys INFTY=sys.maxsize INFTY sys.maxsize sys maxsize sys.setrecursionlimit(100000) sys.setrecursionlimit sys setrecursionlimit 100000 def readinput():
    n=int(input())
    nList=[]
    for _ in range(n+1):
        nList.append([])
    for _ in range(1,n):
        u,v,w=map(int,input().split())
        nList[u].append((v,w))
        nList[v].append((u,w))

    return n,nList readinput n=int(input()) n int(input()) int input() input nList=[] nList [] for _ in range(n+1):
        nList.append([])
     _ range(n+1) range n+1 n 1 nList.append([]) nList.append nList append [] for _ in range(1,n):
        u,v,w=map(int,input().split())
        nList[u].append((v,w))
        nList[v].append((u,w))

     _ range(1,n) range 1 n u,v,w=map(int,input().split()) u map(int,input().split()) map int input().split() ().split () input split v w nList[u].append((v,w)) [u].append [u] nList u append (v,w) v w nList[v].append((u,w)) [v].append [v] nList v append (u,w) u w return n,nList return n,nList n nList WHITE=0 WHITE 0 GRAY=1 GRAY 1 BLACK=2 BLACK 2 status=[] status [] color=[] color [] def dfs(s,nList):
    for u,w in nList[s]:
        if status[u]==WHITE:
            if w%2==0:
                color[u]=color[s]
            else:
                color[u]=(color[s]+1)%2
            status[u]=GRAY
            dfs(u,nList)
    status[s]=BLACK dfs for u,w in nList[s]:
        if status[u]==WHITE:
            if w%2==0:
                color[u]=color[s]
            else:
                color[u]=(color[s]+1)%2
            status[u]=GRAY
            dfs(u,nList)
     u w nList[s] nList s if status[u]==WHITE:
            if w%2==0:
                color[u]=color[s]
            else:
                color[u]=(color[s]+1)%2
            status[u]=GRAY
            dfs(u,nList)
     status[u]==WHITE status[u] status u WHITE if w%2==0:
                color[u]=color[s]
            else:
                color[u]=(color[s]+1)%2
             w%2==0 w%2 w 2 0 color[u]=color[s] color[u] color u color[s] color s color[u]=(color[s]+1)%2 color[u] color u (color[s]+1)%2 color[s]+1 color[s] color s 1 2 status[u]=GRAY status[u] status u GRAY dfs(u,nList) dfs u nList status[s]=BLACK status[s] status s BLACK s s nList nList def main(n,nList):
    global status
    global color

    status=[WHITE]*(n+1)
    color=[WHITE]*(n+1)
    dfs(1,nList)

    for i in range(1,n+1):
        print(color[i])
     main global status global color status=[WHITE]*(n+1) status [WHITE]*(n+1) [WHITE] WHITE n+1 n 1 color=[WHITE]*(n+1) color [WHITE]*(n+1) [WHITE] WHITE n+1 n 1 dfs(1,nList) dfs 1 nList for i in range(1,n+1):
        print(color[i])
     i range(1,n+1) range 1 n+1 n 1 print(color[i]) print color[i] color i n n nList nList if __name__=='__main__':
    n,nList=readinput()
    main(n,nList)
    #print(ans) __name__=='__main__' __name__ '__main__' n,nList=readinput() n readinput() readinput nList main(n,nList) main n nList n,nList=readinput() readinput() n INFTY=sys.maxsize sys.maxsize INFTY def readinput():
    n=int(input())
    nList=[]
    for _ in range(n+1):
        nList.append([])
    for _ in range(1,n):
        u,v,w=map(int,input().split())
        nList[u].append((v,w))
        nList[v].append((u,w))

    return n,nList def readinput():
    n=int(input())
    nList=[]
    for _ in range(n+1):
        nList.append([])
    for _ in range(1,n):
        u,v,w=map(int,input().split())
        nList[u].append((v,w))
        nList[v].append((u,w))

    return n,nList readinput WHITE=0 0 WHITE color=[] [] color def main(n,nList):
    global status
    global color

    status=[WHITE]*(n+1)
    color=[WHITE]*(n+1)
    dfs(1,nList)

    for i in range(1,n+1):
        print(color[i])
     def main(n,nList):
    global status
    global color

    status=[WHITE]*(n+1)
    color=[WHITE]*(n+1)
    dfs(1,nList)

    for i in range(1,n+1):
        print(color[i])
     main GRAY=1 1 GRAY BLACK=2 2 BLACK def dfs(s,nList):
    for u,w in nList[s]:
        if status[u]==WHITE:
            if w%2==0:
                color[u]=color[s]
            else:
                color[u]=(color[s]+1)%2
            status[u]=GRAY
            dfs(u,nList)
    status[s]=BLACK def dfs(s,nList):
    for u,w in nList[s]:
        if status[u]==WHITE:
            if w%2==0:
                color[u]=color[s]
            else:
                color[u]=(color[s]+1)%2
            status[u]=GRAY
            dfs(u,nList)
    status[s]=BLACK dfs status=[] [] status nList=readinput() readinput() nList
import sys
INFTY=sys.maxsize
sys.setrecursionlimit(100000)

def readinput():
    n=int(input())
    nList=[]
    for _ in range(n+1):
        nList.append([])
    for _ in range(1,n):
        u,v,w=map(int,input().split())
        nList[u].append((v,w))
        nList[v].append((u,w))

    return n,nList

WHITE=0
GRAY=1
BLACK=2
status=[]
color=[]

def dfs(s,nList):
    for u,w in nList[s]:
        if status[u]==WHITE:
            if w%2==0:
                color[u]=color[s]
            else:
                color[u]=(color[s]+1)%2
            status[u]=GRAY
            dfs(u,nList)
    status[s]=BLACK

def main(n,nList):
    global status
    global color

    status=[WHITE]*(n+1)
    color=[WHITE]*(n+1)
    dfs(1,nList)

    for i in range(1,n+1):
        print(color[i])
    

if __name__=='__main__':
    n,nList=readinput()
    main(n,nList)
    #print(ans)
