import java.util.*

fun main(args: Array<String>) {
    val inputCount = readLine()!!.toInt()
    val nodeList = mutableListOf<Node>()
    val map = mutableMapOf<Int, MutableMap<Int, Long>>()
    nodeList.add(Node(0))
    (1..inputCount - 1).forEach {
        val inpt = readLine()!!.split(" ")
        val (a,b) = inpt.take(2).map { it.toInt() - 1 }
        listOf(a,b).forEach {
            if(!map.containsKey(it)) {
                map[it] = mutableMapOf()
            }
        }
        val len = inpt.last().toLong()
        map[a]!![b] = len
        map[b]!![a] = len
        nodeList.add(Node(it))
    }

    nodeList[0].col = Col.Black
    val queue = LinkedList<Int>()
    queue.add(0)
    while (queue.isNotEmpty()) {
        val current = queue.pop()
        map[current]!!.forEach {
            if(nodeList[it.key].col == Col.None) {
                if(it.value % 2 == 0.toLong()) {
                    nodeList[it.key] .col = nodeList[current].col
                } else if(nodeList[current].col == Col.Black) {
                    nodeList[it.key].col = Col.White
                } else {
                    nodeList[it.key].col = Col.Black
                }
                queue.add(it.key)
            }
        }
    }
    nodeList.forEach { println(if (it.col == Col.Black) "0" else "1") }
}

class Node(val id:Int) {
    var col = Col.None
}

enum class Col {
    None,
    Black,
    White
}