import java.util.concurrent.LinkedBlockingDeque

fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    data class Connect(val to: Long, val w: Long)

    val n = readLine()?.toInt() ?: return
    val vertexes = Array(n) { -1L }
    val connections = hashMapOf<Long, MutableList<Connect>>()
    repeat(n - 1) {
        val (u, v, w) = longList()
        val ui = u - 1
        val vi = v - 1
        connections.getOrPut(ui) { mutableListOf() }
            .add(Connect(vi, w))
        connections.getOrPut(vi) { mutableListOf() }
            .add(Connect(ui, w))
    }

    val f = connections.keys.first()
    val arrived = Array(n) { false }
    val queue = LinkedBlockingDeque<Pair<Long, Long>>()
    queue.offer(Pair(f, 0L))
    arrived[f.toInt()] = true
    vertexes[f.toInt()] = 0L
    while (queue.isNotEmpty()) {
        val (p, d) = queue.poll()
        val conn = connections[p]
        conn?.forEach {
            if (!arrived[it.to.toInt()]) {
                arrived[it.to.toInt()] = true
                vertexes[it.to.toInt()] = d + it.w
                queue.offer(Pair(it.to, d + it.w))
            }
        }
    }
    buildString {
        vertexes.forEach {
            appendln(if (it % 2 == 0L) 0 else 1)
        }
    }.let {
        println(it.trimIndent())
    }
}
