Scanf.scanf "%d %d %d %d" (fun n m s t ->
    let s = s - 1 in
    let t = t - 1 in
    let yen = Array.make n [] in
    let snk = Array.make n [] in
    for i = 1 to m do
        Scanf.scanf " %d %d %d %d" (fun u v a b ->
            let u = u - 1 in let v = v - 1 in
            yen.(u) <- (a, v) :: yen.(u);
            yen.(v) <- (a, u) :: yen.(v);
            snk.(u) <- (b, v) :: snk.(u);
            snk.(v) <- (b, u) :: snk.(v);
        )
    done;
    let sentinel = max_int in

    let module S = Set.Make (struct type t = int * int let compare = compare end) in
    let dijkstra_from s nei =
        let dist = Array.make n sentinel in
        let rec loop set =
            if S.is_empty set then () else
                let ((cost, node) as elt) = S.min_elt set in
                let set = S.remove elt set in
                let set = List.fold_left (fun acc (c, next) ->
                    if dist.(next) > cost + c then (
                        dist.(next) <- cost + c;
                        S.add (cost + c, next) acc
                    ) else acc) set nei.(node)
                in
                loop set
        in
        dist.(s) <- 0;
        loop (S.singleton (0, s));
        dist
    in

    let d1 = dijkstra_from s yen in 
    let d2 = dijkstra_from t snk in 

    let maxes = Array.make n 0 in

    let rec loop i mx =
        if i < 0 then mx else
            let d = d1.(i) in
            let e = d2.(i) in
            if d = sentinel || e = sentinel then loop (i - 1) mx else
                let c = 1_000_000_000_000_000 - d - e in
                let m = max mx c in
                let () = maxes.(i) <- m in
                loop (i - 1) m
    in
    let _ = loop (n - 1) 0 in
    Array.iter (Printf.printf "%d\n") maxes;
)