import collections
def resolve():
    N = int(input())
    VVW = [list(map(int, input().split())) for _ in range(N-1)]
    adjs = [[] for _ in range(N)]
    for vvw in VVW:
        adjs[vvw[0]-1].append([vvw[1]-1, vvw[2]])
        adjs[vvw[1]-1].append([vvw[0]-1, vvw[2]])

    result = [None for _ in range(N)]
    deq = collections.deque([[0, 0]])
    result[0] = "0"

    while deq:
        node, cost = deq.popleft()
        for adj in adjs[node]:
            nextnode, nextcost = adj[0], adj[1]
            if result[nextnode] is not None:
                continue
            if nextcost%2 == 0:
                result[nextnode] = result[node]
            else:
                result[nextnode] = "1" if result[node] == "0" else "0"
            deq.append([nextnode, nextcost])
    
    [print(r) for r in result]



if '__main__' == __name__:
    resolve() import collections collections def resolve():
    N = int(input())
    VVW = [list(map(int, input().split())) for _ in range(N-1)]
    adjs = [[] for _ in range(N)]
    for vvw in VVW:
        adjs[vvw[0]-1].append([vvw[1]-1, vvw[2]])
        adjs[vvw[1]-1].append([vvw[0]-1, vvw[2]])

    result = [None for _ in range(N)]
    deq = collections.deque([[0, 0]])
    result[0] = "0"

    while deq:
        node, cost = deq.popleft()
        for adj in adjs[node]:
            nextnode, nextcost = adj[0], adj[1]
            if result[nextnode] is not None:
                continue
            if nextcost%2 == 0:
                result[nextnode] = result[node]
            else:
                result[nextnode] = "1" if result[node] == "0" else "0"
            deq.append([nextnode, nextcost])
    
    [print(r) for r in result] resolve N = int(input()) N int(input()) int input() input list(map(int, input().split())) for _ in range(N-1) for _ in range(N-1) _ range(N-1) range N-1 N 1 for _ in range(N-1) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split VVW = [list(map(int, input().split())) for _ in range(N-1)] VVW [list(map(int, input().split())) for _ in range(N-1)] [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] adjs = [[] for _ in range(N)] adjs [[] for _ in range(N)] for vvw in VVW:
        adjs[vvw[0]-1].append([vvw[1]-1, vvw[2]])
        adjs[vvw[1]-1].append([vvw[0]-1, vvw[2]])

     vvw VVW adjs[vvw[0]-1].append([vvw[1]-1, vvw[2]]) [vvw[0]-1].append [vvw[0]-1] adjs vvw[0]-1 vvw[0] vvw 0 1 append [vvw[1]-1, vvw[2]] vvw[1]-1 vvw[1] vvw 1 1 vvw[2] vvw 2 adjs[vvw[1]-1].append([vvw[0]-1, vvw[2]]) [vvw[1]-1].append [vvw[1]-1] adjs vvw[1]-1 vvw[1] vvw 1 1 append [vvw[0]-1, vvw[2]] vvw[0]-1 vvw[0] vvw 0 1 vvw[2] vvw 2 None for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) None result = [None for _ in range(N)] result [None for _ in range(N)] deq = collections.deque([[0, 0]]) deq collections.deque([[0, 0]]) collections.deque collections deque [[0, 0]] [0, 0] 0 0 result[0] = "0" result[0] result 0 "0" while deq:
        node, cost = deq.popleft()
        for adj in adjs[node]:
            nextnode, nextcost = adj[0], adj[1]
            if result[nextnode] is not None:
                continue
            if nextcost%2 == 0:
                result[nextnode] = result[node]
            else:
                result[nextnode] = "1" if result[node] == "0" else "0"
            deq.append([nextnode, nextcost])
    
     deq node, cost = deq.popleft() node deq.popleft() deq.popleft deq popleft cost for adj in adjs[node]:
            nextnode, nextcost = adj[0], adj[1]
            if result[nextnode] is not None:
                continue
            if nextcost%2 == 0:
                result[nextnode] = result[node]
            else:
                result[nextnode] = "1" if result[node] == "0" else "0"
            deq.append([nextnode, nextcost])
    
     adj adjs[node] adjs node nextnode, nextcost = adj[0], adj[1] nextnode adj[0] adj 0 nextcost adj[1] adj 1 if result[nextnode] is not None:
                continue
             result[nextnode] is not None result[nextnode] result nextnode None continue if nextcost%2 == 0:
                result[nextnode] = result[node]
            else:
                result[nextnode] = "1" if result[node] == "0" else "0"
             nextcost%2 == 0 nextcost%2 nextcost 2 0 result[nextnode] = result[node] result[nextnode] result nextnode result[node] result node result[nextnode] = "1" if result[node] == "0" else "0" result[nextnode] result nextnode "1" if result[node] == "0" else "0" result[node] == "0" result[node] result node "0" "1" "0" deq.append([nextnode, nextcost]) deq.append deq append [nextnode, nextcost] nextnode nextcost print(r) for r in result for r in result r result for r in result print(r) print r [print(r) for r in result] if '__main__' == __name__:
    resolve() '__main__' == __name__ '__main__' __name__ resolve() resolve def resolve():
    N = int(input())
    VVW = [list(map(int, input().split())) for _ in range(N-1)]
    adjs = [[] for _ in range(N)]
    for vvw in VVW:
        adjs[vvw[0]-1].append([vvw[1]-1, vvw[2]])
        adjs[vvw[1]-1].append([vvw[0]-1, vvw[2]])

    result = [None for _ in range(N)]
    deq = collections.deque([[0, 0]])
    result[0] = "0"

    while deq:
        node, cost = deq.popleft()
        for adj in adjs[node]:
            nextnode, nextcost = adj[0], adj[1]
            if result[nextnode] is not None:
                continue
            if nextcost%2 == 0:
                result[nextnode] = result[node]
            else:
                result[nextnode] = "1" if result[node] == "0" else "0"
            deq.append([nextnode, nextcost])
    
    [print(r) for r in result] def resolve():
    N = int(input())
    VVW = [list(map(int, input().split())) for _ in range(N-1)]
    adjs = [[] for _ in range(N)]
    for vvw in VVW:
        adjs[vvw[0]-1].append([vvw[1]-1, vvw[2]])
        adjs[vvw[1]-1].append([vvw[0]-1, vvw[2]])

    result = [None for _ in range(N)]
    deq = collections.deque([[0, 0]])
    result[0] = "0"

    while deq:
        node, cost = deq.popleft()
        for adj in adjs[node]:
            nextnode, nextcost = adj[0], adj[1]
            if result[nextnode] is not None:
                continue
            if nextcost%2 == 0:
                result[nextnode] = result[node]
            else:
                result[nextnode] = "1" if result[node] == "0" else "0"
            deq.append([nextnode, nextcost])
    
    [print(r) for r in result] resolve
import collections
def resolve():
    N = int(input())
    VVW = [list(map(int, input().split())) for _ in range(N-1)]
    adjs = [[] for _ in range(N)]
    for vvw in VVW:
        adjs[vvw[0]-1].append([vvw[1]-1, vvw[2]])
        adjs[vvw[1]-1].append([vvw[0]-1, vvw[2]])

    result = [None for _ in range(N)]
    deq = collections.deque([[0, 0]])
    result[0] = "0"

    while deq:
        node, cost = deq.popleft()
        for adj in adjs[node]:
            nextnode, nextcost = adj[0], adj[1]
            if result[nextnode] is not None:
                continue
            if nextcost%2 == 0:
                result[nextnode] = result[node]
            else:
                result[nextnode] = "1" if result[node] == "0" else "0"
            deq.append([nextnode, nextcost])
    
    [print(r) for r in result]



if '__main__' == __name__:
    resolve()