import sys
sys.setrecursionlimit(2000000)

N = int(input())
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
    u,v,w = map(int,input().split())
    edges[u].append((v,w))
    edges[v].append((u,w))
color = [-1]*(N+1)
def dfs(n,p,c):
    color[n]=c
    for nx,w in edges[n]:
        if nx != p:
            if w % 2 == 0:
                nxC = c
            else:
                nxC = (c+1)%2
            dfs(nx,n,nxC)

dfs(1,0,0)
for i in range(1,N+1):
    print(color[i]) import sys sys sys.setrecursionlimit(2000000) sys.setrecursionlimit sys setrecursionlimit 2000000 N = int(input()) N int(input()) int input() input [] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [] edges = [[] for _ in range(N+1)] edges [[] for _ in range(N+1)] for _ in range(N-1):
    u,v,w = map(int,input().split())
    edges[u].append((v,w))
    edges[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 edges[u].append((v,w)) [u].append [u] edges u append (v,w) v w edges[v].append((u,w)) [v].append [v] edges v append (u,w) u w color = [-1]*(N+1) color [-1]*(N+1) [-1] -1 N+1 N 1 def dfs(n,p,c):
    color[n]=c
    for nx,w in edges[n]:
        if nx != p:
            if w % 2 == 0:
                nxC = c
            else:
                nxC = (c+1)%2
            dfs(nx,n,nxC) dfs color[n]=c color[n] color n c for nx,w in edges[n]:
        if nx != p:
            if w % 2 == 0:
                nxC = c
            else:
                nxC = (c+1)%2
            dfs(nx,n,nxC) nx w edges[n] edges n if nx != p:
            if w % 2 == 0:
                nxC = c
            else:
                nxC = (c+1)%2
            dfs(nx,n,nxC) nx != p nx p if w % 2 == 0:
                nxC = c
            else:
                nxC = (c+1)%2
             w % 2 == 0 w % 2 w 2 0 nxC = c nxC c nxC = (c+1)%2 nxC (c+1)%2 c+1 c 1 2 dfs(nx,n,nxC) dfs nx n nxC n n p p c c dfs(1,0,0) dfs 1 0 0 for i in range(1,N+1):
    print(color[i]) i range(1,N+1) range 1 N+1 N 1 print(color[i]) print color[i] color i color = [-1]*(N+1) [-1]*(N+1) color w = map(int,input().split()) map(int,input().split()) w u,v,w = map(int,input().split()) map(int,input().split()) u N = int(input()) int(input()) N edges = [[] for _ in range(N+1)] [[] for _ in range(N+1)] edges def dfs(n,p,c):
    color[n]=c
    for nx,w in edges[n]:
        if nx != p:
            if w % 2 == 0:
                nxC = c
            else:
                nxC = (c+1)%2
            dfs(nx,n,nxC) def dfs(n,p,c):
    color[n]=c
    for nx,w in edges[n]:
        if nx != p:
            if w % 2 == 0:
                nxC = c
            else:
                nxC = (c+1)%2
            dfs(nx,n,nxC) dfs v,w = map(int,input().split()) map(int,input().split()) v
import sys
sys.setrecursionlimit(2000000)

N = int(input())
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
    u,v,w = map(int,input().split())
    edges[u].append((v,w))
    edges[v].append((u,w))
color = [-1]*(N+1)
def dfs(n,p,c):
    color[n]=c
    for nx,w in edges[n]:
        if nx != p:
            if w % 2 == 0:
                nxC = c
            else:
                nxC = (c+1)%2
            dfs(nx,n,nxC)

dfs(1,0,0)
for i in range(1,N+1):
    print(color[i])