
type color = Black | White
type node = {color: color option; children: (int * int) list}

let from_white tree =
  let rec inner aux idx =
    match tree.(idx).color with
    | Some _ -> ()
    | None ->
       if aux mod 2 = 0 then
         begin
           tree.(idx) <- {tree.(idx) with color = Some White};
           List.iter (fun (idx', w) -> inner (aux + w) idx') tree.(idx).children
         end
       else 
         begin
           tree.(idx) <- {tree.(idx) with color = Some Black};
           List.iter (fun (idx', w) -> inner (aux + w) idx') tree.(idx).children
         end
  in inner 0 0; tree

let str_of_color = function None -> "N" | Some Black -> "1" | Some White -> "0"

let tree_to_answer tree =
  Array.iter (fun node -> node.color |> str_of_color |> print_endline) tree

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let tree = Array.make n {color = None; children = []} in
  for i = 1 to n - 1 do 
    Scanf.scanf "%d %d %d\n"
      (fun u v w ->
        tree.(u-1) <- {color=None; children = (v-1, w)::tree.(u-1).children};
        tree.(v-1) <- {color=None; children = (u-1, w)::tree.(v-1).children}
      )
  done;
  from_white tree
  |> tree_to_answer
