def abc126_d():
    import sys
    sys.setrecursionlimit(10010010)
    read = sys.stdin.buffer.read
    inp = iter(map(int, read().split()))

    N = next(inp)
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        u = next(inp) - 1
        v = next(inp) - 1
        w = next(inp)
        G[u].append((v, w))
        G[v].append((u, w))

    color = [-1] * N
    color[0] = 0

    def dfs(u):
        for v, w in G[u]:
            if color[v] != -1: continue
            if w % 2 == 0:
                color[v] = color[u]
            else:
                color[v] = abs(color[u] - 1)
            dfs(v)

    dfs(0)
    print(*color, sep='\n')

if __name__ == '__main__':
    abc126_d() def abc126_d():
    import sys
    sys.setrecursionlimit(10010010)
    read = sys.stdin.buffer.read
    inp = iter(map(int, read().split()))

    N = next(inp)
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        u = next(inp) - 1
        v = next(inp) - 1
        w = next(inp)
        G[u].append((v, w))
        G[v].append((u, w))

    color = [-1] * N
    color[0] = 0

    def dfs(u):
        for v, w in G[u]:
            if color[v] != -1: continue
            if w % 2 == 0:
                color[v] = color[u]
            else:
                color[v] = abs(color[u] - 1)
            dfs(v)

    dfs(0)
    print(*color, sep='\n') abc126_d import sys sys sys.setrecursionlimit(10010010) sys.setrecursionlimit sys setrecursionlimit 10010010 read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read inp = iter(map(int, read().split())) inp iter(map(int, read().split())) iter map(int, read().split()) map int read().split() ().split () read split N = next(inp) N next(inp) next inp [] 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 = next(inp) - 1
        v = next(inp) - 1
        w = next(inp)
        G[u].append((v, w))
        G[v].append((u, w))

     _ range(N-1) range N-1 N 1 u = next(inp) - 1 u next(inp) - 1 next(inp) next inp 1 v = next(inp) - 1 v next(inp) - 1 next(inp) next inp 1 w = next(inp) w next(inp) next inp G[u].append((v, w)) [u].append [u] G u append (v, w) v w G[v].append((u, w)) [v].append [v] G v append (u, w) u w color = [-1] * N color [-1] * N [-1] -1 N color[0] = 0 color[0] color 0 0 def dfs(u):
        for v, w in G[u]:
            if color[v] != -1: continue
            if w % 2 == 0:
                color[v] = color[u]
            else:
                color[v] = abs(color[u] - 1)
            dfs(v)

     dfs for v, w in G[u]:
            if color[v] != -1: continue
            if w % 2 == 0:
                color[v] = color[u]
            else:
                color[v] = abs(color[u] - 1)
            dfs(v)

     v w G[u] G u if color[v] != -1: continue
             color[v] != -1 color[v] color v -1 if w % 2 == 0:
                color[v] = color[u]
            else:
                color[v] = abs(color[u] - 1)
             w % 2 == 0 w % 2 w 2 0 color[v] = color[u] color[v] color v color[u] color u color[v] = abs(color[u] - 1) color[v] color v abs(color[u] - 1) abs color[u] - 1 color[u] color u 1 dfs(v) dfs v u u dfs(0) dfs 0 print(*color, sep='\n') print *color color sep='\n' sep '\n' if __name__ == '__main__':
    abc126_d() __name__ == '__main__' __name__ '__main__' abc126_d() abc126_d def abc126_d():
    import sys
    sys.setrecursionlimit(10010010)
    read = sys.stdin.buffer.read
    inp = iter(map(int, read().split()))

    N = next(inp)
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        u = next(inp) - 1
        v = next(inp) - 1
        w = next(inp)
        G[u].append((v, w))
        G[v].append((u, w))

    color = [-1] * N
    color[0] = 0

    def dfs(u):
        for v, w in G[u]:
            if color[v] != -1: continue
            if w % 2 == 0:
                color[v] = color[u]
            else:
                color[v] = abs(color[u] - 1)
            dfs(v)

    dfs(0)
    print(*color, sep='\n') def abc126_d():
    import sys
    sys.setrecursionlimit(10010010)
    read = sys.stdin.buffer.read
    inp = iter(map(int, read().split()))

    N = next(inp)
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        u = next(inp) - 1
        v = next(inp) - 1
        w = next(inp)
        G[u].append((v, w))
        G[v].append((u, w))

    color = [-1] * N
    color[0] = 0

    def dfs(u):
        for v, w in G[u]:
            if color[v] != -1: continue
            if w % 2 == 0:
                color[v] = color[u]
            else:
                color[v] = abs(color[u] - 1)
            dfs(v)

    dfs(0)
    print(*color, sep='\n') abc126_d
def abc126_d():
    import sys
    sys.setrecursionlimit(10010010)
    read = sys.stdin.buffer.read
    inp = iter(map(int, read().split()))

    N = next(inp)
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        u = next(inp) - 1
        v = next(inp) - 1
        w = next(inp)
        G[u].append((v, w))
        G[v].append((u, w))

    color = [-1] * N
    color[0] = 0

    def dfs(u):
        for v, w in G[u]:
            if color[v] != -1: continue
            if w % 2 == 0:
                color[v] = color[u]
            else:
                color[v] = abs(color[u] - 1)
            dfs(v)

    dfs(0)
    print(*color, sep='\n')

if __name__ == '__main__':
    abc126_d()