import java.util.*

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

    repeat(n - 1) {
        val (u, v, w) = readLine()!!.split(' ').map { it.toInt() }
        graph.add(u, v, w)
    }

    graph.solve().forEach {
        println(it)
    }
}

private class Graph(val n: Int) {

    private val adjacencyMap = mutableMapOf<Int, MutableMap<Int, Int>>()

    fun add(u: Int, v: Int, w: Int) {
        if (!adjacencyMap.containsKey(u)) {
            adjacencyMap[u] = mutableMapOf()
        }
        adjacencyMap[u]!![v] = w

        if (!adjacencyMap.containsKey(v)) {
            adjacencyMap[v] = mutableMapOf()
        }
        adjacencyMap[v]!![u] = w
    }

    fun solve(): List<Int> {

        val visited = mutableMapOf<Int, Int>()
        val queue: Queue<Int> = ArrayDeque<Int>()

        queue.add(1)
        visited[1] = 0

        while (queue.isNotEmpty()) {
            val e = queue.remove()

            adjacencyMap[e]!!.forEach {
                if (visited.containsKey(it.key)) {
                    return@forEach
                }

                queue.add(it.key)
                visited[it.key] = visited[e]!! + it.value
            }
        }

        return (1..n).map {
            if (visited[it]!! % 2 == 0) 0 else 1
        }
    }

}