let tap f x = f x; x

let n = Scanf.sscanf (read_line ()) "%d" @@ fun n  -> n
let e = Array.init (n - 1) @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d %d" @@ fun u v w -> (u, v, w)

let e = tap
  (fun tbl -> Array.iter (fun (u, v, w) -> Hashtbl.add tbl (u - 1) ((v - 1), w); Hashtbl.add tbl (v - 1) ((u - 1), w)) e)
  (Hashtbl.create n)


let f d =
  let que = Queue.create () in
  Queue.add (0, 0) que;
  while not (Queue.is_empty que) do
    let (i, w) = Queue.pop que in
    d.(i) <- w;
    List.iter (fun (a, b) -> if d.(a) = -1 then Queue.add (a, w + b) que) @@ Hashtbl.find_all e i
  done

let () =
  let d = Array.make n (-1) in
  f d;
  d |> Array.map (fun i -> string_of_int (i mod 2)) |> Array.iter print_endline