import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val tree = Array.fill[List[(Int, Int)]](N+1)(Nil)
  for (_ <- 1 to N-1) {
    val u, v, w = in.next().toInt
    tree(u) = (v, w) :: tree(u)
    tree(v) = (u, w) :: tree(v)
  }

  //
  val dp = new Array[Boolean](N+1)
  val ans = new Array[Int](N+1)

  val stack = new scala.collection.mutable.Stack[(Int, Int)] // (node, color)
  stack.push((1, 0))

  while (!stack.isEmpty) {
    val (node, color) = stack.pop()
    if (!dp(node)) {
      ans(node) = color

      for ((e, d) <- tree(node) if !dp(e)) {
        val nxColor = (color + (d % 2)) % 2
        stack.push((e, nxColor))
      }

      dp(node) = true
    }
  }


  for(i <- 1 to N)
    pw.println(ans(i))
  pw.flush()
}



class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
