import sys, math, collections, heapq, itertools

F = sys.stdin

def single_input(): return F.readline().strip("\n")

def line_input(): return F.readline().strip("\n").split()



def solve():

    N = int(single_input())

    edge = [[] for i in range(N)]

    for i in range(N-1):

        u, v, w = list(map(int, line_input()))

        edge[u-1].append((v-1, w))

        edge[v-1].append((u-1, w))

    

    col = [-1] * N

    que = collections.deque()

    que.append((0, 0))

    while que:

        nownode, nowdist = que.popleft()

        if col[nownode] == -1:

            col[nownode] = nowdist

            for nextnode, weight in edge[nownode]:

                if col[nextnode] == -1:

                    que.append((nextnode, nowdist + weight))

    for i in range(N):

        print((col[i] % 2))



    return 0

  

if __name__ == "__main__":

    solve()
import sys

from collections import deque



def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    Edge = [[] for _ in range(N)]

    for _ in range(N - 1):

        u, v, w = list(map(int, input().split()))

        Edge[u-1].append((v-1, w))

        Edge[v-1].append((u-1, w))



    Col = [-1] * N

    q = deque()

    q.append((0, 0, 0)) #now, pre, dist

    while q:

        nn, pn, dist = q.pop()

        if Col[nn] == -1:

            Col[nn] = dist % 2

            for nextN, addW in Edge[nn]:

                if pn != nextN:

                    q.append((nextN, nn, dist + addW))

    print(("\n".join(map(str, Col))))



    return 0



if __name__ == "__main__":

    solve()
import sys, math, collections, heapq, itertools

F = sys.stdin


def single_input():
    return F.readline().strip("\n")


def line_input():
    return F.readline().strip("\n").split()


def solve():
    N = int(single_input())
    edge = [[] for i in range(N)]
    for i in range(N - 1):
        u, v, w = list(map(int, line_input()))
        edge[u - 1].append((v - 1, w))
        edge[v - 1].append((u - 1, w))
    col = [-1] * N
    que = collections.deque()
    que.append((0, 0))
    while que:
        nownode, nowdist = que.popleft()
        if col[nownode] == -1:
            col[nownode] = nowdist
            for nextnode, weight in edge[nownode]:
                if col[nextnode] == -1:
                    que.append((nextnode, nowdist + weight))
    for i in range(N):
        print((col[i] % 2))
    return 0


if __name__ == "__main__":
    solve()

import sys
from collections import deque


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    Edge = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = list(map(int, input().split()))
        Edge[u - 1].append((v - 1, w))
        Edge[v - 1].append((u - 1, w))
    Col = [-1] * N
    q = deque()
    q.append((0, 0, 0))  # now, pre, dist
    while q:
        nn, pn, dist = q.pop()
        if Col[nn] == -1:
            Col[nn] = dist % 2
            for nextN, addW in Edge[nn]:
                if pn != nextN:
                    q.append((nextN, nn, dist + addW))
    print(("\n".join(map(str, Col))))
    return 0


if __name__ == "__main__":
    solve()

-import sys, math, collections, heapq, itertools - -F = sys.stdin - - -def single_input(): -    return F.readline().strip("\n") - - -def line_input(): -    return F.readline().strip("\n").split() +import sys +from collections import deque -    N = int(single_input()) -    edge = [[] for i in range(N)] -    for i in range(N - 1): -        u, v, w = list(map(int, line_input())) -        edge[u - 1].append((v - 1, w)) -        edge[v - 1].append((u - 1, w)) -    col = [-1] * N -    que = collections.deque() -    que.append((0, 0)) -    while que: -        nownode, nowdist = que.popleft() -        if col[nownode] == -1: -            col[nownode] = nowdist -            for nextnode, weight in edge[nownode]: -                if col[nextnode] == -1: -                    que.append((nextnode, nowdist + weight)) -    for i in range(N): -        print((col[i] % 2)) +    input = sys.stdin.readline +    N = int(eval(input())) +    Edge = [[] for _ in range(N)] +    for _ in range(N - 1): +        u, v, w = list(map(int, input().split())) +        Edge[u - 1].append((v - 1, w)) +        Edge[v - 1].append((u - 1, w)) +    Col = [-1] * N +    q = deque() +    q.append((0, 0, 0))  # now, pre, dist +    while q: +        nn, pn, dist = q.pop() +        if Col[nn] == -1: +            Col[nn] = dist % 2 +            for nextN, addW in Edge[nn]: +                if pn != nextN: +                    q.append((nextN, nn, dist + addW)) +    print(("\n".join(map(str, Col))))