object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._

    val N = readLine().toInt

    val distance = Array.fill(N+1, N+1)(-1)
    (0 until N - 1). map { _ =>
      val Array(u, v, w) = readLine().split(" ").map(_.toInt)
      (u - 1, v - 1, w % 2)
    }. foreach { e =>
      val (u, v, w) = e
      distance(u)(v) = w
      distance(v)(u) = w
    }

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

    def dfs(u: Int): Unit =
      if (!visited(u)) {
        visited(u) = true
        (0 until N) foreach { v =>
          if (distance(u)(v) == 0) {
            color(v) = color(u)
            dfs(v)
          } else if (distance(u)(v) == 1) {
            color(v) = 1 - color(u)
            dfs(v)
          }
        }
      }

    dfs(0)
    color.foreach(println)
  }

}
