open Scanf
open Printf

let n = sscanf (read_line ()) "%d" (fun x -> x);;
let paths =  Hashtbl.create 10000;;
let () = 
  for i = 0 to n-2 do
    sscanf (read_line ()) "%d %d %d" (
      fun u v w -> 
        Hashtbl.add paths u (v,w);
        Hashtbl.add paths v (u,w)
    )
  done;;

let dfs ()=
  let tbl = Hashtbl.create n in
  let rec loop stack now_len =
    match stack with
      [] -> ()
    | (x,len) :: rest -> 
      let () = Hashtbl.add tbl x (len + now_len) in 
      let node_list = Hashtbl.find_all paths x in
      let next_list = List.filter 
          (fun tupl -> (not (Hashtbl.mem tbl (fst tupl)))) node_list in
      let () = loop next_list (len + now_len) in
      loop rest len
  in loop [(1,0)] 0;(* node 1 をrootとしてみなして、サイズ0を入れる *)
  tbl;;

let ans_tbl = dfs();;
let () = 
  for i = 1 to n do
    if (Hashtbl.find ans_tbl i) mod 2 = 0 then
      printf "%d\n" 0
    else 
      printf "%d\n" 1
  done;;
