let n = Int(readLine()!)!
var ans = Array(repeating:-1, count:n)

for i in 0..<n-1 {
  let l = readLine()!.split(separator:" ").map{ Int($0)! }
  let u = l[0]-1, v = l[1]-1, w = l[2]
  if ans[u] >= 0 {
    if w%2==0 {ans[v] = ans[u]}
    else {ans[v] = 1-ans[u]}
  } else if ans[v] >= 0 {
    if w%2==0 {ans[u] = ans[v]}
    else {ans[u] = 1-ans[v]}
  } else {
    ans[u] = 0
    if w%2==0 {ans[v] = ans[u]}
    else {ans[v] = 1-ans[u]}
  }
}

for i in 0..<n {
  print(ans[i])
}