let n = Scanf.scanf " %d" (+) 0
let g = Array.make n []
let rec f v p c =
  Printf.printf "%d\n" @@ c;
  List.iter (fun (u, w) -> if u <> p then f u v @@ if w mod 2 = 0 then c else 1 - c) g.(v)
let _ =
  for _ = 1 to n - 1 do
    Scanf.scanf " %d %d %d" @@ fun u v w ->
      g.(u - 1) <- (v - 1, w) :: g.(u - 1); g.(v - 1) <- (u - 1, w) :: g.(v - 1) done;
  f 0 (-1) 0