import sys
sys.setrecursionlimit(10**7)
n=int(input())
edge=[[] for _ in range(n)]
dist=[-1]*n
for i in range(n-1):
    x,y,z=map(int,input().split())
    edge[x-1].append([y-1,z])
    edge[y-1].append([x-1,z])
def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1])
dfs(0,0)
print(*[i%2 for i in dist],sep='\n') import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 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) [] edge=[[] for _ in range(n)] edge [[] for _ in range(n)] dist=[-1]*n dist [-1]*n [-1] -1 n for i in range(n-1):
    x,y,z=map(int,input().split())
    edge[x-1].append([y-1,z])
    edge[y-1].append([x-1,z]) i range(n-1) range n-1 n 1 x,y,z=map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split y z edge[x-1].append([y-1,z]) [x-1].append [x-1] edge x-1 x 1 append [y-1,z] y-1 y 1 z edge[y-1].append([x-1,z]) [y-1].append [y-1] edge y-1 y 1 append [x-1,z] x-1 x 1 z def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1]) dfs dist[node]=d dist[node] dist node d for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1]) i edge[node] edge node if dist[i[0]]==-1:
            dfs(i[0],d+i[1]) dist[i[0]]==-1 dist[i[0]] dist i[0] i 0 -1 dfs(i[0],d+i[1]) dfs i[0] i 0 d+i[1] d i[1] i 1 node node d d dfs(0,0) dfs 0 0 i%2 for i in dist for i in dist i dist for i in dist i%2 i 2 print(*[i%2 for i in dist],sep='\n') print *[i%2 for i in dist] [i%2 for i in dist] sep='\n' sep '\n' y,z=map(int,input().split()) map(int,input().split()) y def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1]) def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1]) dfs x,y,z=map(int,input().split()) map(int,input().split()) x n=int(input()) int(input()) n dist=[-1]*n [-1]*n dist z=map(int,input().split()) map(int,input().split()) z edge=[[] for _ in range(n)] [[] for _ in range(n)] edge
import sys
sys.setrecursionlimit(10**7)
n=int(input())
edge=[[] for _ in range(n)]
dist=[-1]*n
for i in range(n-1):
    x,y,z=map(int,input().split())
    edge[x-1].append([y-1,z])
    edge[y-1].append([x-1,z])
def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1])
dfs(0,0)
print(*[i%2 for i in dist],sep='\n')