import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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

    dist = [-1] * N
    color = [0] * N
    dist[0] = 0
    queue = deque([0])
    while queue:
        v = queue.popleft()
        for nv, cost in G[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v] + cost
                color[nv] = dist[nv] % 2
                queue.append(nv)

    print(*color, sep='\n')
    return


if __name__ == '__main__':
    main() import sys sys from collections import deque read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 def main():
    N = int(readline())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = map(int, readline().split())
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    dist = [-1] * N
    color = [0] * N
    dist[0] = 0
    queue = deque([0])
    while queue:
        v = queue.popleft()
        for nv, cost in G[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v] + cost
                color[nv] = dist[nv] % 2
                queue.append(nv)

    print(*color, sep='\n')
    return main N = int(readline()) N int(readline()) int readline() readline [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] G = [[] for _ in range(N)] G [[] for _ in range(N)] for _ in range(N - 1):
        u, v, w = map(int, readline().split())
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

     _ range(N - 1) range N - 1 N 1 u, v, w = map(int, readline().split()) u map(int, readline().split()) map int readline().split() ().split () readline split v w G[u - 1].append((v - 1, w)) [u - 1].append [u - 1] G u - 1 u 1 append (v - 1, w) v - 1 v 1 w G[v - 1].append((u - 1, w)) [v - 1].append [v - 1] G v - 1 v 1 append (u - 1, w) u - 1 u 1 w dist = [-1] * N dist [-1] * N [-1] -1 N color = [0] * N color [0] * N [0] 0 N dist[0] = 0 dist[0] dist 0 0 queue = deque([0]) queue deque([0]) deque [0] 0 while queue:
        v = queue.popleft()
        for nv, cost in G[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v] + cost
                color[nv] = dist[nv] % 2
                queue.append(nv)

     queue v = queue.popleft() v queue.popleft() queue.popleft queue popleft for nv, cost in G[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v] + cost
                color[nv] = dist[nv] % 2
                queue.append(nv)

     nv cost G[v] G v if dist[nv] == -1:
                dist[nv] = dist[v] + cost
                color[nv] = dist[nv] % 2
                queue.append(nv)

     dist[nv] == -1 dist[nv] dist nv -1 dist[nv] = dist[v] + cost dist[nv] dist nv dist[v] + cost dist[v] dist v cost color[nv] = dist[nv] % 2 color[nv] color nv dist[nv] % 2 dist[nv] dist nv 2 queue.append(nv) queue.append queue append nv print(*color, sep='\n') print *color color sep='\n' sep '\n' return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.readline sys.stdin.readline readline INF = 1 << 60 1 << 60 INF def main():
    N = int(readline())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = map(int, readline().split())
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    dist = [-1] * N
    color = [0] * N
    dist[0] = 0
    queue = deque([0])
    while queue:
        v = queue.popleft()
        for nv, cost in G[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v] + cost
                color[nv] = dist[nv] % 2
                queue.append(nv)

    print(*color, sep='\n')
    return def main():
    N = int(readline())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = map(int, readline().split())
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    dist = [-1] * N
    color = [0] * N
    dist[0] = 0
    queue = deque([0])
    while queue:
        v = queue.popleft()
        for nv, cost in G[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v] + cost
                color[nv] = dist[nv] % 2
                queue.append(nv)

    print(*color, sep='\n')
    return main readlines = sys.stdin.readlines sys.stdin.readlines readlines read = sys.stdin.read sys.stdin.read read
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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

    dist = [-1] * N
    color = [0] * N
    dist[0] = 0
    queue = deque([0])
    while queue:
        v = queue.popleft()
        for nv, cost in G[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v] + cost
                color[nv] = dist[nv] % 2
                queue.append(nv)

    print(*color, sep='\n')
    return


if __name__ == '__main__':
    main()
