object Main {

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

    val N = sc.nextInt()

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

    def dfs(root: Int, E: IndexedSeq[Seq[(Int, Byte)]]): IndexedSeq[Int] = {
      import scala.collection.immutable.Queue
      val visited = new Array[Boolean](N)
      val color = new Array[Int](N)
      visited(root) = true

      def recursive(queue: Queue[Int]): Unit =
        if (queue.nonEmpty) {
          val (u, dequeued) = queue.dequeue
          recursive(
            E(u). collect {
              case (v, w) if !visited(v) =>
                visited(v) = true
                if (w == 0)
                  color(v) = color(u)
                else
                  color(v) = 1 - color(u)
                v
            }. foldLeft(dequeued)((q, n) => q.enqueue(n)))
        }

      recursive(Queue[Int]().enqueue(root))
      color
    }

    println(dfs(ru, E).mkString("\n"))
  }

}