macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(Debug)]
pub struct WeightedGraph<T> {
    graph: Vec<Vec<(usize, T)>>,
}
impl<T: Clone> WeightedGraph<T> {
    pub fn new(n: usize) -> WeightedGraph<T> {
        WeightedGraph {
            graph: vec![vec![]; n],
        }
    }
    pub fn add_edge(&mut self, u: usize, v: usize, c: T) {
        self.graph[u].push((v, c.clone()));
        self.graph[v].push((u, c));
    }
}
impl WeightedGraph<usize> {
    pub fn dijkstra(&mut self, s: usize) -> Vec<usize> {
        use std::collections::BinaryHeap;
        const INF: usize = std::usize::MAX;
        let mut cost = vec![INF; self.graph.len()];
        let mut heap = BinaryHeap::new();
        cost[s] = 0;
        heap.push((Rev(0), s));
        while let Some((d, u)) = heap.pop() {
            let d = d.0;
            for &(v, c) in &self.graph[u] {
                if cost[v] > d + c {
                    cost[v] = d + c;
                    heap.push((Rev(d + c), v));
                }
            }
        }
        cost
    }
}
fn main() {
    input! { n, m, s: usize1, t: usize1, uvab: [(usize1, usize1, usize, usize); m] };
    const X: usize = 1_000_000_000_000_000;
    let mut ga = WeightedGraph::new(n);
    let mut gb = WeightedGraph::new(n);
    for &(u, v, a, b) in &uvab {
        ga.add_edge(u, v, a);
        gb.add_edge(u, v, b);
    }
    let ca = ga.dijkstra(s);
    let cb = gb.dijkstra(t);
    let mut ans = vec![X; n + 1];
    for i in (0..n).rev() {
        ans[i] = std::cmp::min(ans[i + 1], ca[i] + cb[i]);
    }
    for i in 0..n {
        println!("{}", X - ans[i]);
    }
}


Measured memory_bytes: 40692