import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()

    val vst = Array(n) { -1 }

    val al = Array(n) { mutableListOf<Pair<Int, Int>>() }

    for (i in 1 until n) {
        val u = sc.nextInt() - 1
        val v = sc.nextInt() - 1
        val w = sc.nextInt() % 2

        al[u].add(v to w)
        al[v].add(u to w)
    }

    fun op(i: Int, d: Int) {
        if (vst[i] != -1) {
            return
        }
        vst[i] = d % 2
        for (c in al[i]) {
            op(c.first, d + c.second)
        }
    }
    op(0, 0)

    println(vst.joinToString("\r\n"))
}
