object Main {
  import java.util.Scanner

  implicit class RichScanner(sc: Scanner) {
    def readStrings(n: Int): Array[String] = Array.fill(n) { sc.next() }
    def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }
    def readLongs(n: Int): Array[Long] = Array.fill(n) { sc.nextLong() }
    def readLineStrings: Array[String] = sc.nextLine().split(' ')
    def readLineInts: Array[Int] = readLineStrings.map(_.toInt)
    def readLineLongs: Array[Long] = readLineStrings.map(_.toLong)
  }

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  import scala.collection.mutable

  case class Node(id: Int) {
    var neighbours: mutable.Map[Node, Int] = mutable.Map.empty

    def addNeighbour(node: Node, distance: Int) = neighbours.put(node, distance)
  }

  def solve(sc: Scanner): Unit = {
    val N = sc.nextLine().toInt
    val edges = Array.fill(N - 1){ val Array(u, v, w) = sc.readLineInts; (u, v, w) }
    val graph: Map[Int, Node] = (1 to N).map(i => i -> Node(i)).toMap

    edges.foreach { case (u, v, w) => {
      graph(u).addNeighbour(graph(v), w)
      graph(v).addNeighbour(graph(u), w)
    } }

    val isWhite: mutable.Map[Int, Boolean] = mutable.Map.empty

    def colourChildren(from: Int, visited: mutable.Set[Node] = mutable.Set.empty): Unit = {
      if (visited.isEmpty) isWhite.put(from, true)

      val node = graph(from)
      val colour = isWhite(from)

      visited.add(node)

      val children = node.neighbours.keys.filterNot(node => visited.contains(node))
      children.foreach(childNode => {
        if (node.neighbours(childNode) % 2 == 0) {
          isWhite.put(childNode.id, colour)
        } else {
          isWhite.put(childNode.id, !colour)
        }

        colourChildren(childNode.id, visited)
      })
    }

    colourChildren(1)

    (1 to N).foreach(i => println(if (isWhite(i)) "0" else "1"))
  }
}
