import java.io.PrintWriter
import java.util.ArrayDeque

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

data class Edge<T>(val to: Int, var cost: T)

fun solve(out: PrintWriter) {
    val n = readInteger()
    val tmpList = Array(n) { mutableListOf<Edge<Long>>() }
    repeat(n - 1) {
        val (u, v, w) = readLongList()
        tmpList[u.toInt() - 1].add(Edge(v.toInt() - 1, w))
        tmpList[v.toInt() - 1].add(Edge(u.toInt() - 1, w))
    }

    val distance = LongArray(n) { -1L }
    distance[0] = 0L
    val queue = ArrayDeque<Int>()
    queue.addLast(0)
    while (queue.isNotEmpty()) {
        val p = queue.removeFirst()
        for (edge in tmpList[p]) {
            if (distance[edge.to] == -1L) {
                distance[edge.to] = distance[p] + edge.cost
                queue.addLast(edge.to)
            }
        }
    }


    for (i in distance) {
        out.println(if (i % 2 == 0L) 0 else 1)
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)
