import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


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

    color = [False] * N
    color[0] = 0
    q = deque([1])

    while q:
        u = q.popleft()
        c1 = color[u - 1]
        for c, w in edge[u]:
            if color[c - 1] is False:
                q.append(c)
                color[c - 1] = (c1 + w) % 2

    print(*color)


if __name__ == "__main__":
    main() import sys sys from collections import deque def input():
    return sys.stdin.readline().rstrip() input return 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 main():
    N = int(input())
    edge = [[] for _ in range(N + 1)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        edge[u].append((v, w))
        edge[v].append((u, w))

    color = [False] * N
    color[0] = 0
    q = deque([1])

    while q:
        u = q.popleft()
        c1 = color[u - 1]
        for c, w in edge[u]:
            if color[c - 1] is False:
                q.append(c)
                color[c - 1] = (c1 + w) % 2

    print(*color) main N = int(input()) N int(input()) int input() input [] for _ in range(N + 1) for _ in range(N + 1) _ range(N + 1) range N + 1 N 1 for _ in range(N + 1) [] edge = [[] for _ in range(N + 1)] edge [[] for _ in range(N + 1)] for i in range(N - 1):
        u, v, w = map(int, input().split())
        edge[u].append((v, w))
        edge[v].append((u, w))

     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 edge[u].append((v, w)) [u].append [u] edge u append (v, w) v w edge[v].append((u, w)) [v].append [v] edge v append (u, w) u w color = [False] * N color [False] * N [False] False N color[0] = 0 color[0] color 0 0 q = deque([1]) q deque([1]) deque [1] 1 while q:
        u = q.popleft()
        c1 = color[u - 1]
        for c, w in edge[u]:
            if color[c - 1] is False:
                q.append(c)
                color[c - 1] = (c1 + w) % 2

     q u = q.popleft() u q.popleft() q.popleft q popleft c1 = color[u - 1] c1 color[u - 1] color u - 1 u 1 for c, w in edge[u]:
            if color[c - 1] is False:
                q.append(c)
                color[c - 1] = (c1 + w) % 2

     c w edge[u] edge u if color[c - 1] is False:
                q.append(c)
                color[c - 1] = (c1 + w) % 2

     color[c - 1] is False color[c - 1] color c - 1 c 1 False q.append(c) q.append q append c color[c - 1] = (c1 + w) % 2 color[c - 1] color c - 1 c 1 (c1 + w) % 2 c1 + w c1 w 2 print(*color) print *color color if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    edge = [[] for _ in range(N + 1)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        edge[u].append((v, w))
        edge[v].append((u, w))

    color = [False] * N
    color[0] = 0
    q = deque([1])

    while q:
        u = q.popleft()
        c1 = color[u - 1]
        for c, w in edge[u]:
            if color[c - 1] is False:
                q.append(c)
                color[c - 1] = (c1 + w) % 2

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

    color = [False] * N
    color[0] = 0
    q = deque([1])

    while q:
        u = q.popleft()
        c1 = color[u - 1]
        for c, w in edge[u]:
            if color[c - 1] is False:
                q.append(c)
                color[c - 1] = (c1 + w) % 2

    print(*color) main def input():
    return sys.stdin.readline().rstrip() def input():
    return sys.stdin.readline().rstrip() input
import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


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

    color = [False] * N
    color[0] = 0
    q = deque([1])

    while q:
        u = q.popleft()
        c1 = color[u - 1]
        for c, w in edge[u]:
            if color[c - 1] is False:
                q.append(c)
                color[c - 1] = (c1 + w) % 2

    print(*color)


if __name__ == "__main__":
    main()
