n = int(input())
tree = [[] for i in range(n)]
d_list = [0]*n

stack = []
for i in range(n-1):
  u,v,w = map(int,input().split())
  tree[u-1].append((u-1,v-1,w))
  tree[v-1].append((v-1,u-1,w))
while len(tree[0]) > 0:
  e = tree[0].pop()
  stack.append(e)
#print(stack)
while len(stack) > 0:
  u,v, w = stack.pop()
  if d_list[v] == 0:
    d_list[v] = d_list[u]+w
  while len(tree[v]) > 0:
    e = tree[v].pop()
    stack.append(e)
  #print(stack)
for v in d_list:
  if v % 2 == 0:
    print(0)
  else:
    print(1) 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) [] tree = [[] for i in range(n)] tree [[] for i in range(n)] d_list = [0]*n d_list [0]*n [0] 0 n stack = [] stack [] for i in range(n-1):
  u,v,w = map(int,input().split())
  tree[u-1].append((u-1,v-1,w))
  tree[v-1].append((v-1,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 tree[u-1].append((u-1,v-1,w)) [u-1].append [u-1] tree u-1 u 1 append (u-1,v-1,w) u-1 u 1 v-1 v 1 w tree[v-1].append((v-1,u-1,w)) [v-1].append [v-1] tree v-1 v 1 append (v-1,u-1,w) v-1 v 1 u-1 u 1 w while len(tree[0]) > 0:
  e = tree[0].pop()
  stack.append(e)
#print(stack) len(tree[0]) > 0 len(tree[0]) len tree[0] tree 0 0 e = tree[0].pop() e tree[0].pop() [0].pop [0] tree 0 pop stack.append(e) stack.append stack append e while len(stack) > 0:
  u,v, w = stack.pop()
  if d_list[v] == 0:
    d_list[v] = d_list[u]+w
  while len(tree[v]) > 0:
    e = tree[v].pop()
    stack.append(e)
  #print(stack) len(stack) > 0 len(stack) len stack 0 u,v, w = stack.pop() u stack.pop() stack.pop stack pop v w if d_list[v] == 0:
    d_list[v] = d_list[u]+w
   d_list[v] == 0 d_list[v] d_list v 0 d_list[v] = d_list[u]+w d_list[v] d_list v d_list[u]+w d_list[u] d_list u w while len(tree[v]) > 0:
    e = tree[v].pop()
    stack.append(e)
  #print(stack) len(tree[v]) > 0 len(tree[v]) len tree[v] tree v 0 e = tree[v].pop() e tree[v].pop() [v].pop [v] tree v pop stack.append(e) stack.append stack append e for v in d_list:
  if v % 2 == 0:
    print(0)
  else:
    print(1) v d_list if v % 2 == 0:
    print(0)
  else:
    print(1) v % 2 == 0 v % 2 v 2 0 print(0) print 0 print(1) print 1 u,v,w = map(int,input().split()) map(int,input().split()) u v,w = map(int,input().split()) map(int,input().split()) v tree = [[] for i in range(n)] [[] for i in range(n)] tree w = map(int,input().split()) map(int,input().split()) w w = stack.pop() stack.pop() w stack = [] [] stack v, w = stack.pop() stack.pop() v n = int(input()) int(input()) n d_list = [0]*n [0]*n d_list e = tree[0].pop() tree[0].pop() e e = tree[v].pop() tree[v].pop() e u,v, w = stack.pop() stack.pop() u
n = int(input())
tree = [[] for i in range(n)]
d_list = [0]*n

stack = []
for i in range(n-1):
  u,v,w = map(int,input().split())
  tree[u-1].append((u-1,v-1,w))
  tree[v-1].append((v-1,u-1,w))
while len(tree[0]) > 0:
  e = tree[0].pop()
  stack.append(e)
#print(stack)
while len(stack) > 0:
  u,v, w = stack.pop()
  if d_list[v] == 0:
    d_list[v] = d_list[u]+w
  while len(tree[v]) > 0:
    e = tree[v].pop()
    stack.append(e)
  #print(stack)
for v in d_list:
  if v % 2 == 0:
    print(0)
  else:
    print(1)
