fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    
    // parent -> (child, distance)
    val edges = mutableMapOf<Int, MutableList<Pair<Int, Int>>>()
    val visited = BooleanArray(n)
    val distances = IntArray(n)
    
    for (i in 1..n - 1) {
        val (u, v, w) = readInputLine().split(" ").map { it.toInt() }
        val edge1 = edges.get(u) ?: mutableListOf<Pair<Int, Int>>()
        val edge2 = edges.get(v) ?: mutableListOf<Pair<Int, Int>>()
        
        edge1.add(Pair(v, w))
        edge2.add(Pair(u, w))
        
        edges.put(u, edge1)
        edges.put(v, edge2)
    }

    search(1, edges, visited, distances)

    for (d in distances) {
        if (d % 2 == 0) {
            println(0)
        } else {
            println(1)
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}

fun search(parent: Int, edges: MutableMap<Int, MutableList<Pair<Int, Int>>>, visited: BooleanArray, distances: IntArray) {
    visited[parent - 1] = true
    if (!edges.containsKey(parent)) {
        return
    }
    for (e in edges.get(parent)!!) {
        if (visited[e.first - 1]) {
            continue
        }
        visited[e.first - 1] = true
        distances[e.first - 1] = distances[parent - 1] + e.second
        search(e.first, edges, visited, distances)
    }
}
