import scala.collection.mutable

case class Weighted(from: Int, to: Int, weight: Int)

object ABC126D {

  import Competitive._

  def solve(): Unit = {
    val N = nextInt
    val queries = Array.fill[Weighted](N - 1) {
      val u, v = nextInt - 1
      val w = nextInt
      Weighted(u, v, w)
    }

    val edges = queries.flatMap(q => Array[Weighted](q, Weighted(q.to, q.from, q.weight))).groupBy {
      case Weighted(u, _, _) => u
    }
    val black = new mutable.BitSet()
    dfs(black, 0, edges.map { case (k, v) => (k, v.iterator) })
    println((0 until N).map(black).map(b => if (b) "1" else "0").mkString("\n"))
  }

  def dfs(black: mutable.BitSet, start: Int, ki: Map[Int, Iterator[Weighted]]): Unit = {
    val edges = ki(start)
    while (edges.hasNext) {
      val w = edges.next()
      if (w != null && w.weight > 0) {
        black(w.to) = if (w.weight % 2 == 0) black(start) else !black(start)
        dfs(black, w.to, ki)
      }
    }
  }

  solve()
}
object Main extends App{
  ABC126D
}

object Competitive{
  import scala.io.StdIn.readLine

  private var tokenizerBack = readLine().split(" ").iterator
  def tokenizer: Iterator[String] = {
    tokenizerBack = if (tokenizerBack.hasNext) tokenizerBack else readLine().split(" ").iterator
    tokenizerBack
  }

  def next: String = tokenizer.next
  def nextInt: Int = next.toInt
  def nextLong: Long = next.toLong
  def nextIntArray(n: Int): Array[Int] = Array.fill(n)(nextInt)
  def nextLongArray(n: Int): Array[Long] = Array.fill(n)(nextLong)
  def nextArray(n: Int): Array[String] = Array.fill(n)(next)
}