fun main(args: Array<String>) {
    abc126d()
}

fun abc126d() {
    val n = readLine()!!.toInt()
    val edges = (1 until n)
        .map { readLine()!!.split(' ').map { it.toInt() }.let { Edge(it[0] - 1, it[1] - 1, it[2]) } }

    val graph = Array(n) { Vertex(it, mutableListOf(), null) }
    edges.forEach {
        val (from, to, cost) = it
        graph[from].neighbor.add(to to cost)
        graph[to].neighbor.add(from to cost)
    }

    fun dfs(index: Int, isRed: Boolean) {
        val vertex = graph[index]
        vertex.isRed = isRed

        vertex.neighbor.forEach {
            val (to, cost) = it
            if (graph[to].isRed == null) dfs(to, if (cost % 2 == 0) isRed else !isRed)
        }
    }

    dfs(0, true)

    val answer = graph.joinToString(System.lineSeparator()) { if (it.isRed!!) "0" else "1" }

    println(answer)
}

private data class Edge(val from: Int, val to: Int, val cost: Int)
private data class Vertex(val index: Int, val neighbor: MutableList<Pair<Int, Int>>, var isRed: Boolean? = null)
