import java.util.*

data class Edge<T: Comparable<T>>(val from: Int, val to: Int, val weight: T): Comparable<Edge<T>> {
    constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)

    override fun compareTo(other: Edge<T>) = weight.compareTo(other.weight)
}

class Graph<T: Comparable<T>>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {
    val edges = Array(n) { ArrayList<Edge<T>>() }
}

inline fun <reified T: Comparable<T>>dijkstra(g: Graph<T>, s: Int): Pair<Array<T>, Array<Int>> {
    val N = g.n
    val dist = Array(N) { g.inf }
    val prev = Array(N) {-1}

    val Q = PriorityQueue<Edge<T>>()

    dist[s] = g.zero
    Q.add(Edge(-2, s, g.zero))

    while(Q.isNotEmpty()) {
        val e = Q.peek()
        val v = e.to
        Q.poll()

        if (prev[v] != -1) continue
        prev[v] = e.from
        for (i in g.edges[v]) {
            val d = g.plus(dist[v], i.weight)
            if (dist[i.to] > d) {
                dist[i.to] = d
                Q.add(Edge(i.from, i.to, d))
            }
        }
    }

    return Pair(dist, prev)
}

fun main(args: Array<String>) {
    val INF = 1e16.toLong()

    val N = readLine()!!.toInt()
    val g = Graph(N, 0L, INF) { a: Long, b: Long -> a + b }
    for (i in 1..N-1) {
        val (a, b, w) = readLine()!!.split(" ").map { it.toLong() }
        val u = (a - 1).toInt()
        val v = (b - 1).toInt()

        g.edges[u].add(Edge(u, v, w))
        g.edges[v].add(Edge(v, u, w))
    }

    val (dist, prev) = dijkstra(g, 0)

    for (d in dist) {
        println(d % 2)
    }
}
