import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N = gete(int)
    g = [set() for _ in range(N+1)]
    for _ in range(N-1):
        u, v, w = geta(int)
        g[u].add((v, w))
        g[v].add((u, w))

    dist = [-1] * (N+1)
    color = [-1]*(N+1)

    dist[1] = 0
    color[1] = 0

    def dfs(i, d):

        dist[i] = d
        color[i] = 0 if d & 1 == 0 else 1

        for j, wj in g[i]:
            if dist[j] < 0:
                dfs(j, d + wj)

    dfs(1, 0)

    print(*color[1:], sep="\n")


if __name__ == "__main__":
    main() import sys sys from collections import defaultdict readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split()) geta return map(fn, readline().split()) map(fn, readline().split()) map fn readline().split() ().split () readline split fn=lambda s: s.decode() fn lambda s: s.decode() s.decode() s.decode s decode s def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip()) gete return fn(readline().rstrip()) fn(readline().rstrip()) fn readline().rstrip() ().rstrip () readline rstrip fn=lambda s: s.decode() fn lambda s: s.decode() s.decode() s.decode s decode s def main():
    N = gete(int)
    g = [set() for _ in range(N+1)]
    for _ in range(N-1):
        u, v, w = geta(int)
        g[u].add((v, w))
        g[v].add((u, w))

    dist = [-1] * (N+1)
    color = [-1]*(N+1)

    dist[1] = 0
    color[1] = 0

    def dfs(i, d):

        dist[i] = d
        color[i] = 0 if d & 1 == 0 else 1

        for j, wj in g[i]:
            if dist[j] < 0:
                dfs(j, d + wj)

    dfs(1, 0)

    print(*color[1:], sep="\n") main N = gete(int) N gete(int) gete int set() for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) set() set g = [set() for _ in range(N+1)] g [set() for _ in range(N+1)] for _ in range(N-1):
        u, v, w = geta(int)
        g[u].add((v, w))
        g[v].add((u, w))

     _ range(N-1) range N-1 N 1 u, v, w = geta(int) u geta(int) geta int v w g[u].add((v, w)) [u].add [u] g u add (v, w) v w g[v].add((u, w)) [v].add [v] g v add (u, w) u w dist = [-1] * (N+1) dist [-1] * (N+1) [-1] -1 N+1 N 1 color = [-1]*(N+1) color [-1]*(N+1) [-1] -1 N+1 N 1 dist[1] = 0 dist[1] dist 1 0 color[1] = 0 color[1] color 1 0 def dfs(i, d):

        dist[i] = d
        color[i] = 0 if d & 1 == 0 else 1

        for j, wj in g[i]:
            if dist[j] < 0:
                dfs(j, d + wj)

     dfs dist[i] = d dist[i] dist i d color[i] = 0 if d & 1 == 0 else 1 color[i] color i 0 if d & 1 == 0 else 1 d & 1 == 0 d & 1 d 1 0 0 1 for j, wj in g[i]:
            if dist[j] < 0:
                dfs(j, d + wj)

     j wj g[i] g i if dist[j] < 0:
                dfs(j, d + wj)

     dist[j] < 0 dist[j] dist j 0 dfs(j, d + wj) dfs j d + wj d wj i i d d dfs(1, 0) dfs 1 0 print(*color[1:], sep="\n") print *color[1:] color[1:] color 1: 1 sep="\n" sep "\n" if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = gete(int)
    g = [set() for _ in range(N+1)]
    for _ in range(N-1):
        u, v, w = geta(int)
        g[u].add((v, w))
        g[v].add((u, w))

    dist = [-1] * (N+1)
    color = [-1]*(N+1)

    dist[1] = 0
    color[1] = 0

    def dfs(i, d):

        dist[i] = d
        color[i] = 0 if d & 1 == 0 else 1

        for j, wj in g[i]:
            if dist[j] < 0:
                dfs(j, d + wj)

    dfs(1, 0)

    print(*color[1:], sep="\n") def main():
    N = gete(int)
    g = [set() for _ in range(N+1)]
    for _ in range(N-1):
        u, v, w = geta(int)
        g[u].add((v, w))
        g[v].add((u, w))

    dist = [-1] * (N+1)
    color = [-1]*(N+1)

    dist[1] = 0
    color[1] = 0

    def dfs(i, d):

        dist[i] = d
        color[i] = 0 if d & 1 == 0 else 1

        for j, wj in g[i]:
            if dist[j] < 0:
                dfs(j, d + wj)

    dfs(1, 0)

    print(*color[1:], sep="\n") main def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip()) def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip()) gete def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split()) def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split()) geta readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N = gete(int)
    g = [set() for _ in range(N+1)]
    for _ in range(N-1):
        u, v, w = geta(int)
        g[u].add((v, w))
        g[v].add((u, w))

    dist = [-1] * (N+1)
    color = [-1]*(N+1)

    dist[1] = 0
    color[1] = 0

    def dfs(i, d):

        dist[i] = d
        color[i] = 0 if d & 1 == 0 else 1

        for j, wj in g[i]:
            if dist[j] < 0:
                dfs(j, d + wj)

    dfs(1, 0)

    print(*color[1:], sep="\n")


if __name__ == "__main__":
    main()
