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 rec fill cur dist =
            if vertex.(cur - 1) = NA then (
                vertex.(cur - 1) <- if dist mod 2 = 0 then WHITE else BLACK;
                Array.iter (fun (u, v, w) -> if u = cur then fill v (w + dist) else
                                             if v = cur then fill u (w + dist)) arr
            )
        in

        Array.iter (fun (u, v, w) -> if u = 1 then fill v w) arr;
        Array.iter (function
            | WHITE -> print_endline "0"
            | BLACK -> print_endline "1"
            | NA    -> failwith "??") vertex
    in
    main ()