object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()

    val E = Array.fill(N)(new scala.collection.mutable.ArrayBuffer[(Int, Int)]())
    val ru, rv, rw = sc.nextInt()
    E(ru-1).append((rv-1, rw % 2))
    E(rv-1).append((ru-1, rw % 2))
    (0 until N - 2) foreach { _ =>
      val u, v, w = sc.nextInt()
      E(u-1).append((v-1, w % 2))
      E(v-1).append((u-1, w % 2))
    }

    val visited = new Array[Boolean](N)
    val color = new Array[Int](N)
    color(ru) = 0
    visited(ru) = true

    def dfs(u: Int): Unit =
      E(u) foreach { case (v, w) =>
        if (!visited(v)) {
          visited(v) = true
          if (w == 0) {
            color(v) = color(u)
            dfs(v)
          } else {
            color(v) = 1 - color(u)
            dfs(v)
          }
        }
      }

    dfs(ru)
    color.foreach(println)
  }

}
