output_description: Print a coloring of the vertices that satisfies the condition, in N lines. The
  i-th line should contain `0` if Vertex i is painted white and `1` if it is
  painted black.
  
  If there are multiple colorings that satisfy the condition, any of them will
  be accepted.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      u_1 v_1 w_1
      u_2 v_2 w_2
      .
      .
      .
      u_{N - 1} v_{N - 1} w_{N - 1}
attempt: N = int(input())
  UVW = [list(map(int, input().split())) for _ in range(N - 1)]
  
  
  # 奇数だったら塊の色を反転させる
  class Bag:
      def __init__(self, node, color):
          self.bag = [node]
          self.color = color
          print(node, color)
  
      # あるノードを追加する
      def add(self, node):
          self.bag.append(node)
  
      # あるノードの色を変える:
      def change_color(self, color):
          self.color = color
  
      # 同じ色は統合する
      def union(self, Bag):
          self.bag += Bag.bag
  
      def find(self, num):
          if num in self.bag:
              return self.color
          else:
              return -1
  
      def __repr__(self):
          s = "["
          for bg in self.bag:
              s += str(bg) + ","
          s += "]"
          return s + "/" + str(self.color)
  
  
  NODES = []
  
  
  def find_all(node):
      for n in range(len(NODES)):
          i = NODES[n].find(node)
          if i != -1:
              return n
      else:
          return -1
  
  
  color = 0
  for uvw in UVW:
      u = uvw[0] - 1
      v = uvw[1] - 1
      w = uvw[2]
      # print(uvw, tree_color)
      i = find_all(u)
      j = find_all(v)
      if i == -1 and j == -1:
          bg = Bag(u, color)
          if w % 2 == 0:
              bg.add(v)
              NODES.append(bg)
          else:
              NODES.append(bg)
              bg2 = Bag(v, 1 - color)
              NODES.append(bg2)
      elif i != -1 and j == -1:
          if w % 2 == 0:
              NODES[i].add(v)
          else:
              bg2 = Bag(v, 1 - color)
              NODES.append(bg2)
      elif j != -1 and i == -1:
          if w % 2 == 0:
              NODES[j].add(v)
          else:
              bg2 = Bag(u, 1 - color)
              NODES.append(bg2)
      else:
          if w % 2 == 0:
              NODES[i].union(NODES[j])
              del NODES[j]
          else:
              NODES[j].color = 1 - NODES[i].color
  
      # print(NODES)
  
  # for tc in tree_color:
  #    print(tc)
  colors = [0 for _ in range(N)]
  for n in NODES:
      color = n.color
      for nd in n.bag:
          colors[nd] = color
  
  for cl in colors:
      print(cl)
  
problem_description: Statement
  
  We have a tree with N vertices numbered 1 to N. The i-th edge in the tree
  connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is
  to paint each vertex in the tree white or black (it is fine to paint all
  vertices the same color) so that the following condition is satisfied:
  
    * For any two vertices painted in the same color, the distance between them is an even number.
  
  Find a coloring of the vertices that satisfies the condition and print it. It
  can be proved that at least one such coloring exists under the constraints of
  this problem.
samples: [{"input": "3\n    1 2 2\n    2 3 1", "output": "0\n    0\n    1\n    \n\n* * *"}, {"input": "5\n    2 5 2\n    2 3 10\n    1 3 8\n    3 4 2", "output": "1\n    0\n    1\n    0\n    1"}]