import scala.collection.mutable.ArrayBuffer

object Main {

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

    val N = sc.nextInt()

    val distance = Array.fill(N, N)(-1)
    val tree = Array.fill(N)(new ArrayBuffer[Int]())
    val InDegree = Array.fill(N)(0)

    (0 until N - 1). map { _ =>
      val u, v, w = sc.nextInt()
      (u - 1, v - 1, w % 2)
    } foreach { e =>
      val (u, v, w) = e
      distance(u)(v) = w
      InDegree(v) += 1
    }

    InDegree.zipWithIndex.sortBy(_._1) foreach { e =>
      val (_, u) = e
      (0 until N) foreach { v =>
        if (distance(u)(v) >= 0) {
          tree(u).append(v)
        }
      }
    }

    val color = new Array[Int](N)

    def dfs(u: Int): Unit = {
      tree(u) foreach { v =>
        if (distance(u)(v) == 0) {
          color(v) = color(u)
          dfs(v)
        } else {
          color(v) = 1 - color(u)
          dfs(v)
        }
      }
    }

    dfs(0)
    color.foreach(println)
  }

}