import java.util.*

fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val roadList = mutableMapOf<Int, MutableMap<Int, Long>>()
    (1 until n).forEach { a ->
        val (u,v,w) = readLine()!!.split(" ") .map { it.toLong() }
        val (s,e) = listOf(u,v).map { it.toInt() - 1 }
        if(!roadList.containsKey(s)) {
            roadList[s] = mutableMapOf()
        }
        if(!roadList.containsKey(e)) {
            roadList[e] = mutableMapOf()
        }
        roadList[s]!![e] = w
        roadList[e]!![s] = w
    }
    val queue = LinkedList<Int>()
    val color = (0 until  n).map { -1 }.toMutableList()
    color[0] = 0
    queue.push(0)
    while (queue.isNotEmpty()) {
        val current = queue.pop()
        for(next in roadList[current]!!.keys) {
            if(color[next] >= 0) {
                continue
            }
            if(roadList[current]!![next]!! % 2 == 0L) {
                color[next] = color[current]
            } else if(color[current] == 0) {
                color[next] = 1
            } else {
                color[next] = 0
            }
            queue.push(next)
        }
    }
    color.forEach { println(it) }
}
