fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    data class Edge(val node: Int, val distance: Int)

    val graph = mutableMapOf<Int, MutableList<Edge>>()
    repeat(n - 1) {
        val (n1, n2, l) = readLine()!!.split(" ").map(String::toInt)
        graph.getOrPut(n1 - 1, { mutableListOf() }).add(Edge(n2 - 1, l))
        graph.getOrPut(n2 - 1, { mutableListOf() }).add(Edge(n1 - 1, l))
    }

    val even = 0
    val odd = 1

    val result = IntArray(n) { -1 }
    fun dfs(i: Int, dSum: Int) {
        val edges = graph[i]!!

        if (dSum % 2 == 0) {
            result[i] = even
        } else {
            result[i] = odd
        }

        for ((next, distance) in edges) {
            if (result[next] != -1) {
                continue
            }
            dfs(next, dSum + distance)
        }
    }

    dfs(0,0)

    result.forEach(::println)
}