#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    adj = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, input().split())
        adj[u-1].append((v-1,w))
        adj[v-1].append((u-1,w))
    
    queue = deque([0])
    visit = [-1] * N
    visit[0] = 1
    
    while queue:
        now = queue.popleft()
        for u,w in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
    [print(v) for v in visit]


if __name__ == "__main__":
    main() from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right def main():
    N = int(input())
    adj = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, input().split())
        adj[u-1].append((v-1,w))
        adj[v-1].append((u-1,w))
    
    queue = deque([0])
    visit = [-1] * N
    visit[0] = 1
    
    while queue:
        now = queue.popleft()
        for u,w in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
    [print(v) for v in visit] main 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) [] adj = [[] for _ in range(N)] adj [[] for _ in range(N)] for i in range(N-1):
        u, v, w = map(int, input().split())
        adj[u-1].append((v-1,w))
        adj[v-1].append((u-1,w))
    
     i 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 adj[u-1].append((v-1,w)) [u-1].append [u-1] adj u-1 u 1 append (v-1,w) v-1 v 1 w adj[v-1].append((u-1,w)) [v-1].append [v-1] adj v-1 v 1 append (u-1,w) u-1 u 1 w queue = deque([0]) queue deque([0]) deque [0] 0 visit = [-1] * N visit [-1] * N [-1] -1 N visit[0] = 1 visit[0] visit 0 1 while queue:
        now = queue.popleft()
        for u,w in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
     queue now = queue.popleft() now queue.popleft() queue.popleft queue popleft for u,w in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
     u w adj[now] adj now if visit[u] < 0:
                queue.append(u)
                if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
     visit[u] < 0 visit[u] visit u 0 queue.append(u) queue.append queue append u if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
     w % 2 == 0 w % 2 w 2 0 visit[u] = visit[now] visit[u] visit u visit[now] visit now visit[u] = (visit[now]+1) % 2 visit[u] visit u (visit[now]+1) % 2 visit[now]+1 visit[now] visit now 1 2 print(v) for v in visit for v in visit v visit for v in visit print(v) print v [print(v) for v in visit] if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    adj = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, input().split())
        adj[u-1].append((v-1,w))
        adj[v-1].append((u-1,w))
    
    queue = deque([0])
    visit = [-1] * N
    visit[0] = 1
    
    while queue:
        now = queue.popleft()
        for u,w in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
    [print(v) for v in visit] def main():
    N = int(input())
    adj = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, input().split())
        adj[u-1].append((v-1,w))
        adj[v-1].append((u-1,w))
    
    queue = deque([0])
    visit = [-1] * N
    visit[0] = 1
    
    while queue:
        now = queue.popleft()
        for u,w in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
    [print(v) for v in visit] main
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    adj = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, input().split())
        adj[u-1].append((v-1,w))
        adj[v-1].append((u-1,w))
    
    queue = deque([0])
    visit = [-1] * N
    visit[0] = 1
    
    while queue:
        now = queue.popleft()
        for u,w in adj[now]:
            if visit[u] < 0:
                queue.append(u)
                if w % 2 == 0:
                    visit[u] = visit[now]
                else:
                    visit[u] = (visit[now]+1) % 2
    [print(v) for v in visit]


if __name__ == "__main__":
    main()
