from collections import deque

N=int(input())
G=[{} for _ in range(N+1)]

for i in range(N-1):
  u,v,w=map(int,input().split())
  G[u][v]=w
  G[v][u]=w
  
for i in range(1,N+1):
  if len(G[i])==1:
    start=i
    break

def bfs(s):
    seen = [0 for i in range(N+1)]
    d = [0 for i in range(N+1)]
    todo = deque([])
    now = s
    seen[now]=1
    todo.append(now)
    while 1:
      if len(todo)==0:break
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
    return d

d = bfs(start)
for i in range(1,N+1):
  d_ = d[i]
  if d_ % 2 == 0:print(0)
  else:print(1) from collections import deque 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) {} G=[{} for _ in range(N+1)] G [{} for _ in range(N+1)] for i in range(N-1):
  u,v,w=map(int,input().split())
  G[u][v]=w
  G[v][u]=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 G[u][v]=w G[u][v] [u] G u v w G[v][u]=w G[v][u] [v] G v u w for i in range(1,N+1):
  if len(G[i])==1:
    start=i
    break i range(1,N+1) range 1 N+1 N 1 if len(G[i])==1:
    start=i
    break len(G[i])==1 len(G[i]) len G[i] G i 1 start=i start i break def bfs(s):
    seen = [0 for i in range(N+1)]
    d = [0 for i in range(N+1)]
    todo = deque([])
    now = s
    seen[now]=1
    todo.append(now)
    while 1:
      if len(todo)==0:break
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
    return d bfs 0 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) 0 seen = [0 for i in range(N+1)] seen [0 for i in range(N+1)] 0 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) 0 d = [0 for i in range(N+1)] d [0 for i in range(N+1)] todo = deque([]) todo deque([]) deque [] now = s now s seen[now]=1 seen[now] seen now 1 todo.append(now) todo.append todo append now while 1:
      if len(todo)==0:break
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
     1 if len(todo)==0:break
       len(todo)==0 len(todo) len todo 0 a = todo.popleft() a todo.popleft() todo.popleft todo popleft for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
     b G[a] G a if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
     seen[b] == 0 seen[b] seen b 0 seen[b] = 1 seen[b] seen b 1 todo.append(b) todo.append todo append b d[b] += d[a] + G[a][b] d[b] d b d[a] + G[a][b] d[a] d a G[a][b] [a] G a b return d d s s d = bfs(start) d bfs(start) bfs start for i in range(1,N+1):
  d_ = d[i]
  if d_ % 2 == 0:print(0)
  else:print(1) i range(1,N+1) range 1 N+1 N 1 d_ = d[i] d_ d[i] d i if d_ % 2 == 0:print(0)
  else:print(1) d_ % 2 == 0 d_ % 2 d_ 2 0 N=int(input()) int(input()) N G=[{} for _ in range(N+1)] [{} for _ in range(N+1)] G v,w=map(int,input().split()) map(int,input().split()) v u,v,w=map(int,input().split()) map(int,input().split()) u start=i i start d = bfs(start) bfs(start) d d_ = d[i] d[i] d_ w=map(int,input().split()) map(int,input().split()) w def bfs(s):
    seen = [0 for i in range(N+1)]
    d = [0 for i in range(N+1)]
    todo = deque([])
    now = s
    seen[now]=1
    todo.append(now)
    while 1:
      if len(todo)==0:break
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
    return d def bfs(s):
    seen = [0 for i in range(N+1)]
    d = [0 for i in range(N+1)]
    todo = deque([])
    now = s
    seen[now]=1
    todo.append(now)
    while 1:
      if len(todo)==0:break
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
    return d bfs
from collections import deque

N=int(input())
G=[{} for _ in range(N+1)]

for i in range(N-1):
  u,v,w=map(int,input().split())
  G[u][v]=w
  G[v][u]=w
  
for i in range(1,N+1):
  if len(G[i])==1:
    start=i
    break

def bfs(s):
    seen = [0 for i in range(N+1)]
    d = [0 for i in range(N+1)]
    todo = deque([])
    now = s
    seen[now]=1
    todo.append(now)
    while 1:
      if len(todo)==0:break
      a = todo.popleft()
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + G[a][b]
    return d

d = bfs(start)
for i in range(1,N+1):
  d_ = d[i]
  if d_ % 2 == 0:print(0)
  else:print(1)