
object Main extends App {
	val N = scala.io.StdIn.readInt

	val point = new Array[Int](N)

	for(i<-1 until N){
		val Array(u, v, w) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

		if(w%2 != 0){
			point(u-1) = 1
		}
	}

	point.foreach(println)

}