fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val e = (1..n-1).map { readLine()!!.split(" ").map { it.toInt() } }
    val ans = IntArray(n+1){0}
    val visit = BooleanArray(n+1){false}
    val g = readGraph(n,e)
    dfs(1,g,visit,ans,0)
    println( ans.drop(1).map { if(it%2==0) 0 else 1 }.joinToString("\n") )
}

fun dfs (v:Int, g:List<List<Int>>, visit: BooleanArray, ans: IntArray, len: Int){
    ans[v] = len
    g[v].forEach {
        val u = Math.abs(it)
        if(visit[u]) return@forEach
        visit[u] = true
        dfs(u, g, visit, ans, len + if(it<0) 1 else 0)
        visit[u] = false
    }
}

fun readGraph(n: Int, e: List<List<Int>>): List<List<Int>> {
    val adj = Array(n+1) { mutableListOf<Int>() }
    e.forEach {
        val (u,v,w) = it
        adj[u].add(if(w%2==0) v else -v)
        adj[v].add(if(w%2==0) u else -u)
    }
    return adj.map { it.toList() }
}