type v =
    | WHITE
    | BLACK
    | NA

module M = Map.Make (struct type t = int let compare = compare end)

let () =
    let main () =
        let n = Scanf.sscanf (read_line ()) "%d" (fun a -> a) in
        let arr = Array.init (n - 1) (fun _ -> Scanf.sscanf (read_line ()) "%d %d %d" (fun u v w -> u, v, w)) in
        let vertex = Array.make n NA in
        vertex.(0) <- WHITE;
        let map =
            Array.fold_left (fun map (u, v, w) ->
                let map = M.add u ((v, w) :: try M.find u map with _ -> []) map in
                          M.add v ((u, w) :: try M.find v map with _ -> []) map) M.empty arr
        in

        let rec fill cur dist =
            if vertex.(cur - 1) = NA then (
                vertex.(cur - 1) <- if dist mod 2 = 0 then WHITE else BLACK;
                List.iter (fun (v, w) -> fill v (w + dist)) (M.find cur map)
            )
        in

        List.iter (fun (v, w) -> fill v w) (M.find 1 map);
        Array.iter (function
            | WHITE -> print_endline "0"
            | BLACK -> print_endline "1"
            | NA    -> failwith "??") vertex
    in
    main ()
