import kotlin.comparisons.*
import java.util.*

const val MOD = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun ceil(x: Double) = Math.ceil(x)
fun log2(x: Double) = Math.log(x) / 0.6931471805599453

fun main(args: Array<String>) {
  val n = readI()
  val uvw = Array(n + 1) { mutableSetOf<Pair<Int, Int>>() }
  repeat(n - 1) {
    val (u, v, w) = readIs()
    val even = w % 2
    uvw[u].add(v to even)
    uvw[v].add(u to even)
  }
  val d = IntArray(n + 1) { -1 }
  val q = ArrayDeque<Int>()
  d[1] = 0
  q.add(1)
  while (q.isNotEmpty()) {
    val node = q.remove()
    for (cur in uvw[node]) {
      if (d[cur.first] != -1) continue
      d[cur.first] = d[node] xor cur.second
      q.add(cur.first)
    }
  }
  for (i in 1..n) {
    println(d[i])
  }
}
