
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  var color = scala.Array.fill[Int](n)(-1)
  var maps = Array.fill(n)(List.empty[(Int, Int)])
  (0 until n - 1).foreach { _ =>
    val Array(u, v, w) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val uu = u - 1
    val vv = v - 1
    maps(uu) = maps(uu) :+ (vv, w)
    maps(vv) = maps(vv) :+ (uu, w)
  }

  def Search(n: Int, now_color: Int): Unit = {
    if (color(n) != -1) {
      return
    }
    color(n) = now_color

    val nextList = maps(n)
    nextList.foreach { next =>
      val nextPoint = next._1
      val nextLen = next._2
      if (nextLen % 2 == 0) {
        Search(nextPoint, now_color)
      } else {
        if (now_color == 0) {
          Search(nextPoint, 1)
        } else {
          Search(nextPoint, 0)
        }
      }
    }
  }

  Search(0, 0)
  color.foreach(println)
}
