import Foundation
let N = Int(readLine()!)!

// -1: not determined, 0: black, 1: white
var graph: [[Int]] = .init(repeating: [], count: N)
var costs: [[Int]] = .init(repeating: [], count: N)
var colors: [Int] = .init(repeating: -1, count: N)

for _ in 0..<N-1 {
  let input = readLine()!.split(separator: " ").map { Int($0)! }
  graph[input[0] - 1].append(input[1] - 1)
  graph[input[1] - 1].append(input[0] - 1)
  costs[input[0] - 1].append(input[2])
  costs[input[1] - 1].append(input[2])
}


var queue = Set<Int>()
queue.insert(0)
colors[0] = 0

while !queue.isEmpty {
  let top = queue.first!
  queue.remove(top)
  for i in 0..<graph[top].count {
    let u = graph[top][i]
    let w = costs[top][i]
    if colors[u] != -1 {
      continue
    }
    colors[u] = (colors[top] + w)  % 2
    queue.insert(u)
  }
}

colors.forEach { print($0) }

