import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val nodes = Array(n) { Node() }
    for (i in 0 until n - 1) {
        val u = sc.nextInt() - 1
        val v = sc.nextInt() - 1
        val w = sc.nextInt()
        if (w % 2 == 0) {
            nodes[u].even.add(nodes[v])
            nodes[v].even.add(nodes[u])
        } else {
            nodes[u].odd.add(nodes[v])
            nodes[v].odd.add(nodes[u])
        }
    }
    nodes[0].dfs(0)
    println(nodes.map { it.color }.joinToString("\n"))
}

class Node {
    var color = 0
    var decided = false
    val even = ArrayList<Node>()
    val odd = ArrayList<Node>()
    fun dfs(color: Int) {
        this.color = color
        this.decided = true
        even.forEach {
            if (!it.decided) it.dfs(color)
        }
        odd.forEach {
            if (!it.decided) it.dfs(1 - color)
        }
    }
}
