Problem:
Score : 400 points

Problem Statement

Kenkoooo is planning a trip in Republic of Snuke.
In this country, there are n cities and m trains running.
The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally.
Any city can be reached from any city by changing trains.

Two currencies are used in the country: yen and snuuk.
Any train fare can be paid by both yen and snuuk.
The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk.

In a city with a money exchange office, you can change 1 yen into 1 snuuk.
However, when you do a money exchange, you have to change all your yen into snuuk.
That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk.
Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year.

Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling.
It is acceptable to do the exchange in City s or City t.

Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange.
For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years.
You can assume that the trip finishes within the year.

Constraints

2 \leq n \leq 10^5

1 \leq m \leq 10^5

1 \leq s,t \leq n

s \neq t

1 \leq u_i < v_i \leq n

1 \leq a_i,b_i \leq 10^9

If i\neq j, then u_i \neq u_j or v_i \neq v_j.

Any city can be reached from any city by changing trains.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

n m s t
u_1 v_1 a_1 b_1
:
u_m v_m a_m b_m

Output

Print n lines.
In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years.

Sample Input 1

4 3 2 3
1 4 1 100
1 2 1 10
1 3 20 1

Sample Output 1

999999999999998
999999999999989
999999999999979
999999999999897

After 0 years, it is optimal to do the exchange in City 1.

After 1 years, it is optimal to do the exchange in City 2.

Note that City 1 can still be visited even after the exchange office is closed.
Also note that, if it was allowed to keep 1 yen when do the exchange in City 2 and change the remaining yen into snuuk, we could reach City 3 with 999999999999998 snuuk, but this is NOT allowed.

After 2 years, it is optimal to do the exchange in City 3.

After 3 years, it is optimal to do the exchange in City 4.
Note that the same train can be used multiple times.

Sample Input 2

8 12 3 8
2 8 685087149 857180777
6 7 298270585 209942236
2 4 346080035 234079976
2 5 131857300 22507157
4 8 30723332 173476334
2 6 480845267 448565596
1 4 181424400 548830121
4 5 57429995 195056405
7 8 160277628 479932440
1 6 475692952 203530153
3 5 336869679 160714712
2 7 389775999 199123879

Sample Output 2

999999574976994
999999574976994
999999574976994
999999574976994
999999574976994
999999574976994
999999574976994
999999574976994

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>

using namespace std;

struct initon {
    initon() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
} hoee;
//別名
#define int long long
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using dou = double;
using itn = int;
using str = string;
#define F first
#define S second
//定数
const int INF = (int) 1e9 + 100;
const int MINF = (int) -1e9 - 100;
const ll LINF = (ll) 1e18 + 100;
const ll MLINF = (ll) 1e18 - 100;
const double EPS = 1e-9;
const int y4[] = {-1, 1, 0, 0};
const int x4[] = {0, 0, -1, 1};
const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1};

//配列
#define sz(a) (sizeof(a)/sizeof(a[0]))

//コンテナ
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

template<class T> inline void sort(T a[], int len) {
    sort(a, a + len);
}

template<class T> inline void sort(vector<T> a) {
    sort(a.begin(), a.end());
}

template<class T> inline void rsort(T a[], int len) {
    sort(a, a + len, std::greater<T>());
}

template<class T> inline void rsort(vector<T> a) {
    std::sort(a.begin(), a.end(), std::greater<T>());
}

//繰り返し
#define _overloadrep(_1, _2, _3, name, ...) name
# define _rep(i, n) for(int i = 0,RLN = (n); i < RLN ; i++)
#define repi(i, m, n) for(int i = m,RLN = (n); i < RLN ; i++)
#define rep(...) _overloadrep(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rer(i, n) for(int RLN = (n) ,i = RLN; i >= 0 ; i--)
#define reri(i, m, n) for(int RLN = (n) ,i = m-1; i >= n ; i--)
#define rer(...) _overloadrep(__VA_ARGS__,reri,_rer,)(__VA_ARGS__)

// 多次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

#define arcpy(a, b) memcpy(a,b,sizeof(b))

//入力
template<typename T = int>
T in() {
    T x;
    cin >> x;
    return (x);
}

string sin() {
    return in<string>();
}

double din() {
    return in<double>();
}

ll lin() {
    return in<ll>();
}

#define na(a, n) rep(i,n) cin >> a[i];
#define nad(a, n) rep(i,n) cin >> a[i]; a[i]--;
#define nt(a, h, w) rep(hi,h)rep(wi,w) cin >> a[hi][wi];
#define ntd(a, h, w) rep(hi,h)rep(wi,w) cin >> a[hi][wi]; a[hi][wi]--;
#define nctp(a, c) fill(a,c); rep(hi,1,sz(a)+1)rep(wi,1,sz(a[0])+1) cin >> a[hi][wi];
#define addAll(a, n) rep(i,n) a.pb(in());


//出力
template<class T>
void out(T x) {
    if (typeid(x) == typeid(double))cout << fixed << setprecision(10) << x << endl;
    else cout << x << endl;
}
//デバッグ
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

//便利関数
#define bit(n) (1LL<<(n))

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

inline bool inside(int y, int x, int H, int W) {
    return y >= 0 && x >= 0 && y < H && x < W;
}

//mod関連

ll MOD = (int) 1e9 + 7;

class mint {
private:
    ll v;
public:
    static ll mod(ll a) { return (a % MOD + MOD) % MOD; }

    mint(ll a = 0) { this->v = mod(a); };

    mint(const mint &a) { v = a.v; }

    mint operator+(const mint &a) { return mint(v + a.v); }

    mint operator+(const ll a) { return mint(v + a % MOD); }

    mint operator+(const signed a) { return mint(v + a % MOD); }

    friend mint operator+(const ll a, const mint &b) { return mint(a % MOD + b.v); }

    void operator+=(const mint &a) { v = (v + a.v) % MOD; }

    void operator+=(const ll a) { v = mod(v + a % MOD); }

    void operator+=(const signed a) { v = mod(v + a % MOD); }

    friend void operator+=(ll &a, const mint &b) { a = mod(a % MOD + b.v); }

    mint operator-(const mint &a) { return mint(v - a.v); }

    mint operator-(const ll a) { return mint(v - a % MOD); }

    mint operator-(const signed a) { return mint(v - a % MOD); }

    friend mint operator-(const ll a, const mint &b) { return mint(a % MOD - b.v); }

    void operator-=(const mint &a) { v = mod(v - a.v); }

    void operator-=(const ll a) { v = mod(v - a % MOD); }

    void operator-=(const signed a) { v = mod(v - a % MOD); }

    friend void operator-=(ll &a, const mint &b) { a = mod(a % MOD - b.v); }

    mint operator*(const mint &a) { return mint(v * a.v); }

    mint operator*(const ll a) { return mint(v * (a % MOD)); }

    mint operator*(const signed a) { return mint(v * (a % MOD)); }

    friend mint operator*(const ll a, const mint &b) { return mint(a % MOD * b.v); }

    void operator*=(const mint &a) { v = (v * a.v) % MOD; }

    void operator*=(const ll a) { v = mod(v * (a % MOD)); }

    void operator*=(const signed a) { v = mod(v * (a % MOD)); }

    friend void operator*=(ll &a, const mint &b) { a = mod(a % MOD * b.v); }

    mint operator/(const mint &a);

    mint operator/(const ll a);

    mint operator/(const signed a);

    friend mint operator/(const ll a, const mint &b);

    void operator/=(const mint &a);

    void operator/=(const ll a);

    void operator/=(const signed a);

    friend void operator/=(ll &a, const mint &b);


    //単項演算子
    mint operator+() { return *this; }

    mint operator++() {
        v++;
        return *this;
    }

    mint operator++(signed d) {
        mint res = *this;
        v++;
        return res;
    }

    mint operator-() { return operator*(-1); }

    mint operator--() {
        v++;
        return *this;
    }

    void operator--(signed d) {
        mint res = *this;
        v++;
    }

    bool operator==(mint &a) {
        return v == a.v;
    }

    bool operator==(signed a) {
        return v == a;
    }

    friend bool operator==(signed a, mint &b) {
        return a == b.v;
    }

    bool operator!=(mint &a) {
        return v != a.v;
    }

    bool operator!=(signed a) {
        return v != a;
    }

    friend bool operator!=(signed a, mint &b) {
        return a != b.v;
    }

    operator int() { return v; }
};

const int setModMax = 510000;
mint fac[setModMax], finv[setModMax], inv[setModMax];

void setMod() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < setModMax; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

mint minv(ll a) {
    if (fac[0] == 0)setMod();
    if (a < setModMax) return inv[a];
    a %= MOD;
    ll b = MOD, x = 1, y = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        x -= t * y;
        swap(x, y);
    }
    return (x % MOD + MOD) % MOD;
}

mint mpow(mint &v, ll a) {
    ll x = v, n = a, res = 1;
    while (n) {
        if (n & 1)res = (res * x) % MOD;
        x = (x * x) % MOD;
        n >>= 1;
    }
    return res;
}


mint mint::operator/(const mint &a) { return mint(v * minv(a.v)); }

mint mint::operator/(const ll a) { return mint(v * minv(a)); }

mint mint::operator/(const signed a) { return mint(v * minv(a)); }

mint operator/(const ll a, const mint &b) { return mint(a % MOD * minv(b.v)); }

void mint::operator/=(const mint &a) { v = (v * minv(a.v)) % MOD; }

void mint::operator/=(const ll a) { v = mod(v * minv(a)); }

void mint::operator/=(const signed a) { v = mod(v * minv(a)); }

void operator/=(ll &a, const mint &b) { a = mint::mod(a % MOD * minv(b.v)); }

bool isPrime[1010101];
vi primes;

void setPrime() {
    fill(isPrime, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i < sqrt(sz(isPrime)) + 5; ++i) {
        if (!isPrime[i])continue;
        primes.push_back(i);
        for (int j = 2; i * j < sz(isPrime); ++j) {
            isPrime[i * j] = false;
        }
    }
}

mint com(ll n, ll r) {
    if (n < r || n < 0 || r < 0)return 0;
    if (fac[0] == 0)setMod();
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll u(ll a) {
    return a < 0 ? 0 : a;
}

#define inc(s, x, t) s<=x&&x<t
#define MAX(a) numeric_limits<a>::max()

bool bget(ll m, int keta) {
    return (m >> keta) & 1;
}

void compress(int a[], int len) {
    vi b;
    for (int i = 0; i < len; ++i) {
        b.push_back(a[i]);
    }
    sort(b);
    for (int i = 0; i < len; ++i) {
        a[i] = lower_bound(all(b), a[i]) - b.begin();
    }
}

ll ceil(ll a, ll b) {
    return (a + b - 1) / b;
}

ll sqrt(ll a) {
    ll res = (ll) sqrt(a);
    while (res * res < a)res++;
    return res;
}

template<typename T = ll> class graph {
public :
    vector<vector<pair<int, T>>> g;
    int n;

    graph(int n) : n(n) {
        g.resize(n);
    }

    virtual void add(int from, int to, T cost) = 0;
};

template<typename T =ll> class undigraph : public graph<T> {
public:
    using graph<T>::g;
    using graph<T>::n;

    undigraph(int n) : graph<T>(n) {
    }

    void add(int f, int t, T cost = 1) {
        assert(0 <= f && f < n && 0 <= t && t < n);
        g[f].emplace_back(t, cost);
        g[t].emplace_back(f, cost);

    }
};

template<typename T =ll> class digraph : public graph<T> {
public:
    using graph<T>::g;
    using graph<T>::n;

    digraph(int n) : graph<T>(n) {
    }

    void add(int f, int t, T cost = 1) {
        assert(0 <= f && f < n && 0 <= t && t < n);
        g[f].emplace_back(t, cost);
    }
};

template<typename T>
vector<T> dijkstra(const graph<T> &g, int s) {
    assert(inc(0, s, g.n));
    vector<T> dis(g.n, MAX(T));
    priority_queue<pair<T, int>, vector<pair<T, int> >, greater<pair<T, int> > > q;
    dis[s] = 0;
    q.emplace(0, s);
    while (q.size()) {
        T nowc = q.top().F;
        int i = q.top().S;
        q.pop();
        if (dis[i] != nowc)continue;
        for (auto &e: g.g[i]) {
            int to = e.F;
            T cost = nowc + e.S;
            if (dis[to] > cost) {
                dis[to] = cost;
                q.emplace(dis[to], to);
            }
        }
    }
    return dis;
}

#define ans(a) cout<<a<<endl;continue;
#define lower_index(a, v) lower_bound(all(a),v)-a.begin()
#define upper_index(a, v) upper_bound(all(a),v)-a.begin()

ll ma = numeric_limits<ll>::min();
ll mi = numeric_limits<ll>::max();
int N, K, M, H, W, Q, cou, sum, A[101010], B[101010], C[101010];

signed main() {
    int s, t;
    cin >> N >> M >> s >> t;
    s--,t--;
    undigraph<int> Y(N);
    undigraph<int> S(N);
    for (int i = 0; i < M; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        Y.add(u, v, a);
        S.add(u, v, b);
    }
    auto ydis = dijkstra<int>(Y, s);
    auto sdis = dijkstra<int>(S, t);
    vi res(N);
    for (int i = N - 1; i >= 0; --i) {
        res[i] = (ll) 1e15 - ydis[i] - sdis[i];
    }
    for (int i = N - 1; i >= 0; --i) {
        if (i != N - 1)chmax(res[i], res[i + 1]);
    }
    for (int i = 0; i < N; i++) {
        std::cout << res[i] << std::endl;
    }
    return 0;
}