import scala.collection.mutable.HashMap

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    case class Edge(to: Int, d: Int)
    val tree = new HashMap[Int, Array[Edge]]()
    for (i <- 0 until N - 1) {
      val u = sc.nextInt - 1
      val v = sc.nextInt - 1
      val w = sc.nextInt
      if (tree.contains(u)) {
        tree(u) :+= Edge(v, w)
      } else {
        tree += u -> Array(Edge(v, w))
      }
      if (tree.contains(v)) {
        tree(v) :+= Edge(u, w)
      } else {
        tree += v -> Array(Edge(u, w))
      }
    }

    val colorMap = new HashMap[Int, Int]()

    def dfs(node: Int, depth: Int): Unit = {
      if (colorMap.contains(node)) {
        return
      } else {
        colorMap += node -> depth % 2
      }
      for (connected <- tree(node)) {
        dfs(connected.to, depth + connected.d)
      }
    }

    dfs(0, 0)

    for (i <- 0 until N) {
      println(colorMap(i))
    }
  }


}