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[Byte] = {
      import scala.collection.immutable.Queue
      def recursive(
          queue: Queue[Int],
          visited: IndexedSeq[Boolean],
          color: IndexedSeq[Byte]): IndexedSeq[Byte] =
        if (queue.nonEmpty) {
          val (u, dequeued) = queue.dequeue
          val finded = E(u).filter(!visited(_))
          recursive(
            dequeued ++ finded.map(_._1),
            finded.foldLeft(visited)((b, n) =>
              b.updated(n._1, true: Boolean)),
            finded.foldLeft(color)((b, n) =>
              b.updated(n._1, if (n._2 == 0) color(u) else (1 - color(n._1)).toByte)))
        } else color
      
      recursive(
        new Queue[Int]().enqueue(root),
        new Vector[Boolean](N).updated(root, true),
        new Vector[Byte](N))
    }

    dfs(ru, E).foreach(println)
  }

}