import scala.collection.mutable.Stack
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
    case class Edge(to: Int, d: Long)
    val tree = Array.fill[ArrayBuffer[Edge]](N)(new ArrayBuffer[Edge]())
    for (_ <- 0 until N - 1) {
      val u = sc.nextInt - 1
      val v = sc.nextInt - 1
      val w = sc.nextLong
      tree(u) :+= Edge(v, w)
      tree(v) :+= Edge(u, w)
    }

    val colorMap = new Array[Long](N)
    val checked = new ArrayBuffer[Int]()

    def dfs(node: Int): Unit = {
      val stack = new Stack[(Int, Long)]()
      stack.push((node, 0L))
      checked += node
      while (stack.nonEmpty) {
        val (node, d) = stack.pop
        colorMap(node) = d % 2
        for (edge <- tree(node)) {
          if (!checked.contains(edge.to)) {
            checked += edge.to
            val depth = d + edge.d
            colorMap(edge.to) = depth % 2
            stack.push((edge.to, depth))
          }
        }
      }
    }

    dfs(0)

    for (i <- 0 until N) {
      println(colorMap(i))
    }
  }


}