from collections import deque
N = int(input())
connection =[[] for i in range(N)]
for i in range(1,N):
    u,v,w = (int(x) for x in input().split())
    u -=1
    v -=1
    connection[u].append((v,w))
    connection[v].append((u,w))
#
start=0
node =[None]*N
node[start] =0
dq =deque()
dq.append(start)

#
while dq:
    sarch =dq.popleft()
    for nv,w in connection[sarch]:
        if node[nv] is None:
            node[nv] = (node[sarch] +w) %2
            dq.append(nv)   
print(*node,sep="\n") from collections import deque N = int(input()) N int(input()) int input() input [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] connection =[[] for i in range(N)] connection [[] for i in range(N)] for i in range(1,N):
    u,v,w = (int(x) for x in input().split())
    u -=1
    v -=1
    connection[u].append((v,w))
    connection[v].append((u,w))
# i range(1,N) range 1 N int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x u,v,w = (int(x) for x in input().split()) u (int(x) for x in input().split()) v w u -=1 u 1 v -=1 v 1 connection[u].append((v,w)) [u].append [u] connection u append (v,w) v w connection[v].append((u,w)) [v].append [v] connection v append (u,w) u w start=0 start 0 node =[None]*N node [None]*N [None] None N node[start] =0 node[start] node start 0 dq =deque() dq deque() deque dq.append(start) dq.append dq append start while dq:
    sarch =dq.popleft()
    for nv,w in connection[sarch]:
        if node[nv] is None:
            node[nv] = (node[sarch] +w) %2
            dq.append(nv)    dq sarch =dq.popleft() sarch dq.popleft() dq.popleft dq popleft for nv,w in connection[sarch]:
        if node[nv] is None:
            node[nv] = (node[sarch] +w) %2
            dq.append(nv)    nv w connection[sarch] connection sarch if node[nv] is None:
            node[nv] = (node[sarch] +w) %2
            dq.append(nv)    node[nv] is None node[nv] node nv None node[nv] = (node[sarch] +w) %2 node[nv] node nv (node[sarch] +w) %2 node[sarch] +w node[sarch] node sarch w 2 dq.append(nv) dq.append dq append nv print(*node,sep="\n") print *node node sep="\n" sep "\n" dq =deque() deque() dq node =[None]*N [None]*N node connection =[[] for i in range(N)] [[] for i in range(N)] connection v,w = (int(x) for x in input().split()) (int(x) for x in input().split()) v sarch =dq.popleft() dq.popleft() sarch N = int(input()) int(input()) N w = (int(x) for x in input().split()) (int(x) for x in input().split()) w start=0 0 start v -=1 1 v u,v,w = (int(x) for x in input().split()) (int(x) for x in input().split()) u u -=1 1 u
from collections import deque
N = int(input())
connection =[[] for i in range(N)]
for i in range(1,N):
    u,v,w = (int(x) for x in input().split())
    u -=1
    v -=1
    connection[u].append((v,w))
    connection[v].append((u,w))
#
start=0
node =[None]*N
node[start] =0
dq =deque()
dq.append(start)

#
while dq:
    sarch =dq.popleft()
    for nv,w in connection[sarch]:
        if node[nv] is None:
            node[nv] = (node[sarch] +w) %2
            dq.append(nv)   
print(*node,sep="\n")