import sys
sys.setrecursionlimit(10**9)


N = int(input())
to = [[] for _ in range(N)]

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


def dfs(v, color):
    for nv, w in to[v]:
        if color[nv] == -1:
            if w % 2:
                color[nv] = color[v] ^ 1
            else:
                color[nv] = color[v]
            dfs(nv, color)


def main():
    color = [-1] * N
    color[0] = 0
    dfs(0, color)
    print(*color, sep='\n')


if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 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) [] to = [[] for _ in range(N)] to [[] for _ in range(N)] for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1
    to[u].append([v, w])
    to[v].append([u, w]) _ 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 to[u].append([v, w]) [u].append [u] to u append [v, w] v w to[v].append([u, w]) [v].append [v] to v append [u, w] u w def dfs(v, color):
    for nv, w in to[v]:
        if color[nv] == -1:
            if w % 2:
                color[nv] = color[v] ^ 1
            else:
                color[nv] = color[v]
            dfs(nv, color) dfs for nv, w in to[v]:
        if color[nv] == -1:
            if w % 2:
                color[nv] = color[v] ^ 1
            else:
                color[nv] = color[v]
            dfs(nv, color) nv w to[v] to v if color[nv] == -1:
            if w % 2:
                color[nv] = color[v] ^ 1
            else:
                color[nv] = color[v]
            dfs(nv, color) color[nv] == -1 color[nv] color nv -1 if w % 2:
                color[nv] = color[v] ^ 1
            else:
                color[nv] = color[v]
             w % 2 w 2 color[nv] = color[v] ^ 1 color[nv] color nv color[v] ^ 1 color[v] color v 1 color[nv] = color[v] color[nv] color nv color[v] color v dfs(nv, color) dfs nv color v v color color def main():
    color = [-1] * N
    color[0] = 0
    dfs(0, color)
    print(*color, sep='\n') main color = [-1] * N color [-1] * N [-1] -1 N color[0] = 0 color[0] color 0 0 dfs(0, color) dfs 0 color print(*color, sep='\n') print *color color sep='\n' sep '\n' if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main v = u - 1, v - 1 v - 1 v u, v = u - 1, v - 1 u - 1 u v, w = map(int, input().split()) map(int, input().split()) v def dfs(v, color):
    for nv, w in to[v]:
        if color[nv] == -1:
            if w % 2:
                color[nv] = color[v] ^ 1
            else:
                color[nv] = color[v]
            dfs(nv, color) def dfs(v, color):
    for nv, w in to[v]:
        if color[nv] == -1:
            if w % 2:
                color[nv] = color[v] ^ 1
            else:
                color[nv] = color[v]
            dfs(nv, color) dfs u, v, w = map(int, input().split()) map(int, input().split()) u def main():
    color = [-1] * N
    color[0] = 0
    dfs(0, color)
    print(*color, sep='\n') def main():
    color = [-1] * N
    color[0] = 0
    dfs(0, color)
    print(*color, sep='\n') main N = int(input()) int(input()) N w = map(int, input().split()) map(int, input().split()) w to = [[] for _ in range(N)] [[] for _ in range(N)] to
import sys
sys.setrecursionlimit(10**9)


N = int(input())
to = [[] for _ in range(N)]

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


def dfs(v, color):
    for nv, w in to[v]:
        if color[nv] == -1:
            if w % 2:
                color[nv] = color[v] ^ 1
            else:
                color[nv] = color[v]
            dfs(nv, color)


def main():
    color = [-1] * N
    color[0] = 0
    dfs(0, color)
    print(*color, sep='\n')


if __name__ == "__main__":
    main()