#!python3

import sys
sys.setrecursionlimit(10 ** 6)


def LI():
    return list(map(int, input().split()))

# input
N = int(input())
UVW = [LI() for _ in range(N - 1)]


# params
link = [[] for _ in range(N)]
for u, v, w in UVW:
    u -= 1
    v -= 1
    link[u].append((v, w))
    link[v].append((u, w))


def dfs(ans, x):
    for y, w in link[x]:
        if ans[y] is None:
            if w % 2 == 0:
                ans[y] = ans[x]
            else:
                ans[y] = 0 if ans[x] else 1
            dfs(ans, y)


def main():
    ans = [None] * N
    ans[0] = 0
    dfs(ans, 0)
    for a in ans:
        print(a)


if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 def LI():
    return list(map(int, input().split()))

# input LI return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split N = int(input()) N int(input()) int input() input LI() for _ in range(N - 1) for _ in range(N - 1) _ range(N - 1) range N - 1 N 1 for _ in range(N - 1) LI() LI UVW = [LI() for _ in range(N - 1)] UVW [LI() for _ in range(N - 1)] [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] link = [[] for _ in range(N)] link [[] for _ in range(N)] for u, v, w in UVW:
    u -= 1
    v -= 1
    link[u].append((v, w))
    link[v].append((u, w)) u v w UVW u -= 1 u 1 v -= 1 v 1 link[u].append((v, w)) [u].append [u] link u append (v, w) v w link[v].append((u, w)) [v].append [v] link v append (u, w) u w def dfs(ans, x):
    for y, w in link[x]:
        if ans[y] is None:
            if w % 2 == 0:
                ans[y] = ans[x]
            else:
                ans[y] = 0 if ans[x] else 1
            dfs(ans, y) dfs for y, w in link[x]:
        if ans[y] is None:
            if w % 2 == 0:
                ans[y] = ans[x]
            else:
                ans[y] = 0 if ans[x] else 1
            dfs(ans, y) y w link[x] link x if ans[y] is None:
            if w % 2 == 0:
                ans[y] = ans[x]
            else:
                ans[y] = 0 if ans[x] else 1
            dfs(ans, y) ans[y] is None ans[y] ans y None if w % 2 == 0:
                ans[y] = ans[x]
            else:
                ans[y] = 0 if ans[x] else 1
             w % 2 == 0 w % 2 w 2 0 ans[y] = ans[x] ans[y] ans y ans[x] ans x ans[y] = 0 if ans[x] else 1 ans[y] ans y 0 if ans[x] else 1 ans[x] ans x 0 1 dfs(ans, y) dfs ans y ans ans x x def main():
    ans = [None] * N
    ans[0] = 0
    dfs(ans, 0)
    for a in ans:
        print(a) main ans = [None] * N ans [None] * N [None] None N ans[0] = 0 ans[0] ans 0 0 dfs(ans, 0) dfs ans 0 for a in ans:
        print(a) a ans print(a) print a if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main N = int(input()) int(input()) N u -= 1 1 u v -= 1 1 v def LI():
    return list(map(int, input().split()))

# input def LI():
    return list(map(int, input().split()))

# input LI def dfs(ans, x):
    for y, w in link[x]:
        if ans[y] is None:
            if w % 2 == 0:
                ans[y] = ans[x]
            else:
                ans[y] = 0 if ans[x] else 1
            dfs(ans, y) def dfs(ans, x):
    for y, w in link[x]:
        if ans[y] is None:
            if w % 2 == 0:
                ans[y] = ans[x]
            else:
                ans[y] = 0 if ans[x] else 1
            dfs(ans, y) dfs link = [[] for _ in range(N)] [[] for _ in range(N)] link UVW = [LI() for _ in range(N - 1)] [LI() for _ in range(N - 1)] UVW def main():
    ans = [None] * N
    ans[0] = 0
    dfs(ans, 0)
    for a in ans:
        print(a) def main():
    ans = [None] * N
    ans[0] = 0
    dfs(ans, 0)
    for a in ans:
        print(a) main
#!python3

import sys
sys.setrecursionlimit(10 ** 6)


def LI():
    return list(map(int, input().split()))

# input
N = int(input())
UVW = [LI() for _ in range(N - 1)]


# params
link = [[] for _ in range(N)]
for u, v, w in UVW:
    u -= 1
    v -= 1
    link[u].append((v, w))
    link[v].append((u, w))


def dfs(ans, x):
    for y, w in link[x]:
        if ans[y] is None:
            if w % 2 == 0:
                ans[y] = ans[x]
            else:
                ans[y] = 0 if ans[x] else 1
            dfs(ans, y)


def main():
    ans = [None] * N
    ans[0] = 0
    dfs(ans, 0)
    for a in ans:
        print(a)


if __name__ == "__main__":
    main()
