import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        u, v = u - 1, v - 1
        edge[u].append((w, v))
        edge[v].append((w, u))

    q = deque()
    q.append(0)
    color = [-1 for _ in range(N)]
    color[0] = True

    # print(edge)

    while q:
        v = q.popleft()
        for w, nv in edge[v]:
            if color[nv] == -1:
                if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                q.append(nv)

    # print(color)
    for c in color:
        if c:
            print(0)
        else:
            print(1)


if __name__ == '__main__':
    solve() import sys sys from collections import deque input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def solve():
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        u, v = u - 1, v - 1
        edge[u].append((w, v))
        edge[v].append((w, u))

    q = deque()
    q.append(0)
    color = [-1 for _ in range(N)]
    color[0] = True

    # print(edge)

    while q:
        v = q.popleft()
        for w, nv in edge[v]:
            if color[nv] == -1:
                if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                q.append(nv)

    # print(color)
    for c in color:
        if c:
            print(0)
        else:
            print(1) solve N = int(input()) N int(input()) int input() input [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] edge = [[] for _ in range(N)] edge [[] for _ in range(N)] for i in range(N - 1):
        u, v, w = map(int, input().split())
        u, v = u - 1, v - 1
        edge[u].append((w, v))
        edge[v].append((w, u))

     i range(N - 1) range N - 1 N 1 u, v, w = map(int, input().split()) u map(int, input().split()) map int input().split() ().split () input split v w u, v = u - 1, v - 1 u u - 1 u 1 v v - 1 v 1 edge[u].append((w, v)) [u].append [u] edge u append (w, v) w v edge[v].append((w, u)) [v].append [v] edge v append (w, u) w u q = deque() q deque() deque q.append(0) q.append q append 0 -1 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) -1 color = [-1 for _ in range(N)] color [-1 for _ in range(N)] color[0] = True color[0] color 0 True while q:
        v = q.popleft()
        for w, nv in edge[v]:
            if color[nv] == -1:
                if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                q.append(nv)

    # print(color)
     q v = q.popleft() v q.popleft() q.popleft q popleft for w, nv in edge[v]:
            if color[nv] == -1:
                if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                q.append(nv)

    # print(color)
     w nv edge[v] edge v if color[nv] == -1:
                if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                q.append(nv)

    # print(color)
     color[nv] == -1 color[nv] color nv -1 if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                 w % 2 == 0 w % 2 w 2 0 color[nv] = color[v] color[nv] color nv color[v] color v color[nv] = not color[v] color[nv] color nv not color[v] color[v] color v q.append(nv) q.append q append nv for c in color:
        if c:
            print(0)
        else:
            print(1) c color if c:
            print(0)
        else:
            print(1) c print(0) print 0 print(1) print 1 if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input def solve():
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        u, v = u - 1, v - 1
        edge[u].append((w, v))
        edge[v].append((w, u))

    q = deque()
    q.append(0)
    color = [-1 for _ in range(N)]
    color[0] = True

    # print(edge)

    while q:
        v = q.popleft()
        for w, nv in edge[v]:
            if color[nv] == -1:
                if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                q.append(nv)

    # print(color)
    for c in color:
        if c:
            print(0)
        else:
            print(1) def solve():
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        u, v = u - 1, v - 1
        edge[u].append((w, v))
        edge[v].append((w, u))

    q = deque()
    q.append(0)
    color = [-1 for _ in range(N)]
    color[0] = True

    # print(edge)

    while q:
        v = q.popleft()
        for w, nv in edge[v]:
            if color[nv] == -1:
                if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                q.append(nv)

    # print(color)
    for c in color:
        if c:
            print(0)
        else:
            print(1) solve
import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        u, v = u - 1, v - 1
        edge[u].append((w, v))
        edge[v].append((w, u))

    q = deque()
    q.append(0)
    color = [-1 for _ in range(N)]
    color[0] = True

    # print(edge)

    while q:
        v = q.popleft()
        for w, nv in edge[v]:
            if color[nv] == -1:
                if w % 2 == 0:
                    color[nv] = color[v]
                else:
                    color[nv] = not color[v]
                q.append(nv)

    # print(color)
    for c in color:
        if c:
            print(0)
        else:
            print(1)


if __name__ == '__main__':
    solve()
