import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import java.util.ArrayDeque

object Main extends App {
  val n = in.readInt

  case class edge(v:Int, d:Int)
  val tree = Array.fill(n)(mu.ListBuffer.empty[edge])

  Iterator.continually(in.readLine)
    .take(n-1)
    .map(_.split(" ").map(_.toInt))
    .foreach { e =>
      tree(e(0)-1) :+= new edge(e(1)-1, e(2))
      tree(e(1)-1) :+= new edge(e(0)-1, e(2))
    }

  val colors = Array.ofDim[Int](n)
  val visit = Array.ofDim[Boolean](n)

  def dfs(v:Int, d:Int):Unit = {
    // val stk = mu.Stack.empty[edge]
    val stk = new ArrayDeque[edge]
    stk.push(new edge(v, d))

    while(!stk.isEmpty) {
      val v = stk.pop
      if(!visit(v.v)) {
        visit(v.v) = true
        colors(v.v) = if(v.d % 2 == 0) 0 else 1
        for(nv <- tree(v.v) if !visit(nv.v)){
          stk.push(new edge(nv.v, v.d + nv.d))
        }
      }
    }
  }

  dfs(0,0)
  println(colors.mkString("\n"))
}