CodeEff/ECCO huggingface dataset:
# Original solution
import  heapq

n,m,s,t=list(map(int,input().split()))
src = [ tuple( map( int, input().split() ) )   for i in range(m)]

nl=[ [ ] for j in range(n+1) ] 

for u,v,a,b in src:
	nl[u].append( (v,a,b) )
	nl[v].append( (u,a,b) )

#Dijkstra yen
d_y=[ float("inf") ]*(n+1)
d_y[s]=0

Q=[]
heapq.heappush(Q,s)

while Q:
	u=heapq.heappop(Q)
	for v,yen,snuuk in nl[u]:
		alt=d_y[u]+yen
		if d_y[v]> alt:
			d_y[v]=alt
			heapq.heappush(Q,v)

#Dijkstra snuuk
d_s=[ float("inf")]*(n+1)
d_s[t]=0

Q=[]
heapq.heappush(Q,t)

while Q:
	u=heapq.heappop(Q)
	for v,yen,snuuk in nl[u]:
		alt=d_s[u]+snuuk
		if d_s[v]> alt:
			d_s[v]=alt
			heapq.heappush(Q,v)


val=float("inf")
A=[]
for i in range(n,0,-1):
	tmp=d_y[i]+d_s[i]
	val=min(val, tmp)
	A.append(val)

for i in reversed(A):
	print(10**15-i)

# Optimized solution
import  heapq

n,m,s,t=list(map(int,input().split()))
src = [ tuple( map( int, input().split() ) )   for i in range(m)]

nl=[ [ ] for j in range(n+1) ] 

for u,v,a,b in src:
	nl[u].append( (v,a,b) )
	nl[v].append( (u,a,b) )

#Dijkstra yen
d_y=[ float("inf") ]*(n+1)
d_y[s]=0

Q=[]
heapq.heappush(Q, (0,s) )

while Q:
	cost, u=heapq.heappop(Q)
	for v,yen,snuuk in nl[u]:
		if d_y[v] > cost+yen:
			d_y[v]=cost+yen
			heapq.heappush(Q, (d_y[v], v)  )

#Dijkstra snuuk
d_s=[ float("inf")]*(n+1)
d_s[t]=0

Q=[]
heapq.heappush(Q,(0,t) )

while Q:
	cost, u=heapq.heappop(Q)
	for v,yen,snuuk in nl[u]:
		if d_s[v] > cost+snuuk:
			d_s[v]=cost+snuuk
			heapq.heappush(Q, (d_s[v], v)  )


val=float("inf")
A=[]
for i in range(n,0,-1):
	tmp=d_y[i]+d_s[i]
	val=min(val, tmp)
	A.append(val)

for i in reversed(A):
	print(10**15-i)
# Original solution
import heapq as hq

#0 input
INF = 10**16
OKANE = 10**15

N, M, S, T = list(map(int, input().split()))

graph_yen = [[] for _ in range(N+1)]
graph_snk = [[] for _ in range(N+1)]

for i in range(M):
    u, v, a, b = list(map(int, input().split()))
    graph_yen[u].append((v, a))
    graph_yen[v].append((u, a))
    graph_snk[u].append((v, b))
    graph_snk[v].append((u, b))


def dijkstra(st, ryogae, graph):
    dist = [INF]*(N+1)
    hasVisited = [False]*(N+1)
    hasVisited[0] = True
    
    dist[st] = 0
    hasVisited[st] = True
    
    # ryogaeをvisitするまで続く
    cand_list = []
    cr_point = st
    while not hasVisited[ryogae]:
        # 次の候補をheapに入れる
        for neighb in graph[cr_point]:
            if not hasVisited[neighb[0]]:
                cand_list.append([dist[cr_point]+neighb[1], neighb[0]])
            
        #print("cand_list:{}".format(cand_list))
        # 次の候補を確定
        hq.heapify(cand_list)
        while 1:
            next_node = hq.heappop(cand_list)
            if not hasVisited[next_node[1]]:
                break
         
        #print(next_node)
        # distの更新
        cr_point = next_node[1]
        dist[cr_point] = next_node[0]
        hasVisited[cr_point] = True
        
        #print("dist:{}".format(dist))
    
    return dist[ryogae]


min_list = [INF]*(N+1)
for i in range(N-1,-1,-1):
    min_after_i = dijkstra(S,i+1,graph_yen) + dijkstra(T,i+1,graph_snk)
    min_list[i] = min(min_after_i,min_list[i+1])



for i in range(N):
    print((OKANE - min_list[i]))

# Optimized solution
import heapq
n,m,s,t=list(map(int,input().split()))
s-=1
t-=1
Gyen=[dict() for i in range(n)]
Gsnu=[dict() for i in range(n)]
for i in range(m):
    u,v,a,b=list(map(int,input().split()))
    u-=1
    v-=1
    Gyen[u][v]=a
    Gyen[v][u]=a
    Gsnu[u][v]=b
    Gsnu[v][u]=b
def dijkstra(adj, start):
    num = n          # グラフのノード数
    dist = [10**15 for i in range(num)] # 始点から各頂点までの最短距離を格納する
   
    dist[start] = 0
    q = []                  # プライオリティキュー．各要素は，(startからある頂点vまでの仮の距離, 頂点vのID)からなるタプル
    heapq.heappush(q, (0, start)) # 始点をpush
    while (len(q) != 0):
        prov_cost, src = heapq.heappop(q) # pop
        # プライオリティキューに格納されている最短距離が，現在計算できている最短距離より大きければ，distの更新をする必要はない
        if dist[src] < prov_cost:
            continue
        # 他の頂点の探索
        for dest in adj[src]:
            cost = adj[src][dest]
            if dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost # distの更新
                heapq.heappush(q, (dist[dest], dest)) # キューに新たな仮の距離の情報をpush                  
    return dist
CostYen=dijkstra(Gyen,s)
CostSnu=dijkstra(Gsnu,t)
Cost=[0 for i in range(n)]
for i in range(n):
    Cost[i]=CostYen[i]+CostSnu[i]
ans=[0 for i in range(n)]
ans[-1]=Cost[-1]
for i in list(range(n-1))[::-1]:
    ans[i]=min(ans[i+1],Cost[i])
for i in range(n):
    print((10**15-ans[i]))
# Original solution

import heapq as hq

INF = 10**16
OKANE = 10**15



N, M, S, T = list(map(int, input().split()))

graph_yen = [[] for _ in range(N+1)]
graph_snk = [[] for _ in range(N+1)]


for i in range(M):
    u, v, a, b = list(map(int, input().split()))
    graph_yen[u].append((a, v))
    graph_yen[v].append((a, u))
    graph_snk[u].append((b, v))
    graph_snk[v].append((b, u))

def dijkstra(st, graph, N):
    dist = [INF]*(N+1)
    hasVisited = [False]*(N+1)
    hasVisited[0] = True
    
    dist[st] = 0
    hasVisited[st] = True
    
    # startをpushする
    cand_list = []
    hq.heappush(cand_list, (0,st))
    while len(cand_list) != 0:
        nex, node = hq.heappop(cand_list)
        if dist[node] < nex:
            continue

        for nb in graph[node]:
            if dist[nb[1]] > nex+nb[0]:
                dist[nb[1]] = nex+nb[0]
                hq.heappush(cand_list,(dist[nb[1]], nb[1]))
    
    return dist


dist_yen = dijkstra(S,graph_yen, N)
dist_snk = dijkstra(T,graph_snk, N)

del dist_yen[0]
del dist_snk[0]


min_list = [INF]*(N+1)
i = 0
for yen, snk in zip(dist_yen[::-1], dist_snk[::-1]):
    i+=1
    min_after_i = yen+snk
    min_list[i] = min(min_after_i,min_list[i-1])

del min_list[0]

for cost in min_list[::-1]:
    print((OKANE - cost))

# Optimized solution
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


from heapq import heappush, heappop


def dijkstra(graph: list, start, INF=float('inf')) -> list:
    n = len(graph)
    dist = [INF] * n
    visited = [False] * n

    dist[start] = 0
    que = [(0, start)]

    while que:
        cost, cur = heappop(que)

        if visited[cur]:
            continue

        visited[cur] = True

        for nextnode, edgecost in graph[cur]:
            nextcost = cost + edgecost
            if nextcost < dist[nextnode]:
                dist[nextnode] = nextcost
                heappush(que, (nextcost, nextnode))

    return dist

n, m, s, t = li()
s -= 1
t -= 1

yen_graph = [[] for _ in range(n)]
snk_graph = [[] for _ in range(n)]

for _ in range(m):
    u, v, a, b = li()
    u -= 1
    v -= 1

    yen_graph[u].append((v, a))
    yen_graph[v].append((u, a))
    snk_graph[u].append((v, b))
    snk_graph[v].append((u, b))

yen_dist = dijkstra(yen_graph, s)
snk_dist = dijkstra(snk_graph, t)

initial = 10**15

ans = [-1]*n
for i in range(n-1, -1, -1):
    if i == n-1:
        ans[i] = initial - (yen_dist[i] + snk_dist[i])

    else:
        ans[i] = max(ans[i+1], initial - (yen_dist[i] + snk_dist[i]))

for ansi in ans:
    print(ansi)
# Original solution
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N,M,s,t = map(int,input().split())
    INF = 10**15
    
    yedge = [[] for _ in range(N)]
    sedge = [[] for _ in range(N)]
    for _ in range(M):
        u,v,a,b = map(int,input().split())
        yedge[u-1].append((v-1,a))
        yedge[v-1].append((u-1,a))
        sedge[u-1].append((v-1,b))
        sedge[v-1].append((u-1,b))
        
    def dij(x,z):
        q = deque([x])
        go = [INF for _ in range(N)]
        go[x] = 0
        while q:
            now = q.pop()
            for fol,d in z[now]:
                if go[fol] > go[now]+d:
                    go[fol] = go[now]+d
                    q.append(fol)
        return go
        
    y,s = dij(s-1,yedge),dij(t-1,sedge)
    ans = []
    u = 0
    for i,j in zip(y[::-1],s[::-1]):
        u = max(u,INF-i-j) 
        ans.append(u)
        
    print(*ans[::-1],sep="\n")

if __name__ == "__main__":
    main()


# Optimized solution
import sys
input = sys.stdin.buffer.readline
import heapq

def main():
    N,M,s,t = map(int,input().split())
    INF = 10**15
    
    yedge = [[] for _ in range(N)]
    sedge = [[] for _ in range(N)]
    for _ in range(M):
        u,v,a,b = map(int,input().split())
        yedge[u-1].append((a,v-1))
        yedge[v-1].append((a,u-1))
        sedge[u-1].append((b,v-1))
        sedge[v-1].append((b,u-1))
        
    def dij(x,z):
        q = [(0,x)]
        heapq.heapify(q)
        go = [INF for _ in range(N)]
        go[x] = 0
        while q:
            d,now = heapq.heappop(q)
            if go[now] > d:
                continue
            for d,fol in z[now]:
                if go[fol] > go[now]+d:
                    go[fol] = go[now]+d
                    heapq.heappush(q,(go[fol],fol))
        return go
        
    y,s = dij(s-1,yedge),dij(t-1,sedge)
    ans = []
    u = 0
    for i,j in zip(y[::-1],s[::-1]):
        u = max(u,INF-i-j) 
        ans.append(u)
        
    print(*ans[::-1],sep="\n")

if __name__ == "__main__":
    main()
# Original solution
from heapq import heappush, heappop

def dijkstra(s, edge):
    '''
    始点sから各頂点への最短距離を求める
    '''
    d = [float("inf")] * n
    d[s] = 0
    used = [False] * n
    used[s] = True
    edgelist = []

    for e in edge[s]:
        heappush(edgelist, e)

    while edgelist:
        cost, v = heappop(edgelist)
        if used[v]:
            continue
        d[v] = cost
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heappush(edgelist, [e[0] + d[v], e[1]])

    return d


def segfunc(x, y):
    '''
    問題に応じて返り値を設定
    '''
    return min(x, y)


def init(a):
    '''
    配列aで初期化
    '''
    for i in range(n):
        seg[i+num-1] = a[i]    
    for i in range(num-2, -1, -1) :
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])


def update(k, x):
    '''
    a[k]の値をxに更新
    '''
    k += num - 1
    seg[k] = x
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k*2+1], seg[k*2+2])


def query(p, q):
    '''
    [p, q)についてsegfuncを適用したものを返す
    '''
    if q <= p:
        return ide_ele
    
    p += num - 1
    q += num - 2
    res = ide_ele

    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(res, segfunc(seg[p], seg[q]))
    
    return res


n, m, s, t = list(map(int, input().split()))

e1 = [[] for _ in range(n)]
e2 = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = list(map(int, input().split()))
    e1[u-1].append([a, v-1])
    e1[v-1].append([a, u-1])
    e2[u-1].append([b, v-1])
    e2[v-1].append([b, u-1])

d1 = dijkstra(s-1, e1)
d2 = dijkstra(t-1, e2)
dist = [d1[i] + d2[i] for i in range(n)]

num = (2 ** len(bin(n - 1)) - 2)
ide_ele = float('inf')
seg = [ide_ele] * 2 * num
init(dist)

for i in range(n):
    print((10 ** 15 - query(i, n)))

# Optimized solution
from heapq import heappush, heappop

def dijkstra(s, edge):
    '''
    始点sから各頂点への最短距離を求める
    '''
    d = [float("inf")] * n
    d[s] = 0
    used = [False] * n
    used[s] = True
    edgelist = []

    for e in edge[s]:
        heappush(edgelist, e)

    while edgelist:
        cost, v = heappop(edgelist)
        if used[v]:
            continue
        d[v] = cost
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heappush(edgelist, [e[0] + d[v], e[1]])

    return d


n, m, s, t = list(map(int, input().split()))

e1 = [[] for _ in range(n)]
e2 = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = list(map(int, input().split()))
    e1[u-1].append([a, v-1])
    e1[v-1].append([a, u-1])
    e2[u-1].append([b, v-1])
    e2[v-1].append([b, u-1])

d1 = dijkstra(s-1, e1)
d2 = dijkstra(t-1, e2)
dist = [d1[i] + d2[i] for i in range(n)]

res = [0] * n

min_dist = float('inf')
for i in range(n-1, -1, -1):
    min_dist = min(min_dist, dist[i])
    res[i] = 10 ** 15 - min_dist

for v in res:
    print(v)
# Original solution
import heapq
from collections import defaultdict
def gijkstra(n,E,s=1):
    d = [float('inf')]*(n+1)
    p = [-1]*(n+1)
    hq = [(0,s)]
    d[s] = 0
    while hq:
        u = heapq.heappop(hq)[1]
        for v, c in E[u]:
            if d[v] > d[u] + c:
                d[v], p[v] = d[u]+c, u
                heapq.heappush(hq, (d[u]+c, v))
    return d, p

n, m, s, t =  map(int,input().split())
E1 = defaultdict(set)
E2 = defaultdict(set)

for i in range(m):
    u,v,a,b = tuple(map(int,input().split()))
    E1[u].add((v,a))
    E1[v].add((u,a))
    E2[u].add((v,b))
    E2[v].add((u,b))
d1, _ = gijkstra(n,E1,s=s)
d2, _ = gijkstra(n,E2,s=t)
d = [d1[-1] + d2[-1],]
for i in range(n-1,0,-1):
    d = [min(d[0],d1[i]+d2[i])] + d
[print(10**15-c) for c in d]


# Optimized solution
import heapq
from collections import defaultdict
def gijkstra(n,E,s=1):
    d = [float('inf')]*(n+1)
    p = [-1]*(n+1)
    hq = [(0,s)]
    d[s] = 0
    while hq:
        u = heapq.heappop(hq)[1]
        for v, c in E[u]:
            if d[v] > d[u] + c:
                d[v], p[v] = d[u]+c, u
                heapq.heappush(hq, (d[u]+c, v))
    return d, p

n, m, s, t =  map(int,input().split())
E1 = defaultdict(set)
E2 = defaultdict(set)

for i in range(m):
    u,v,a,b = tuple(map(int,input().split()))
    E1[u].add((v,a))
    E1[v].add((u,a))
    E2[u].add((v,b))
    E2[v].add((u,b))
d1, _ = gijkstra(n,E1,s=s)
d2, _ = gijkstra(n,E2,s=t)
d = [d1[-1] + d2[-1],]
for i in range(n-1,0,-1):
    d.append(min(d[-1],d1[i]+d2[i]))
[print(10**15-c) for c in reversed(d)]
# Original solution
import collections
import heapq


class Dijkstra():
    def __init__(self):
        self.e = collections.defaultdict(list)

    def add(self, u, v, d):
        self.e[u].append([v, d])
        self.e[v].append([u, d])

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def search(self, s):
        """
        :param s: 始点
        :return: 始点から各点までの最短経路
        """
        d = collections.defaultdict(lambda: float('inf'))
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    heapq.heappush(q, (vd, uv))

        return d


N, M, S, T = list(map(int, input().split()))
UVAB = [list(map(int, input().split())) for i in range(M)]
graph1 = Dijkstra()
graph2 = Dijkstra()

for u, v, a, b in UVAB:
    graph1.add(u, v, a)
    graph2.add(u, v, b)

result_a = graph1.search(S)
result_b = graph2.search(T)
ans_list = [float('inf')]
for i in range(N, 0, -1):
    cur = result_a[i] + result_b[i]
    if cur > ans_list[-1]:
        cur = ans_list[-1]
    ans_list.append(cur)

for i in range(len(ans_list[1:])):
    print((10**15-ans_list[-(i+1)]))

# Optimized solution
import collections
import heapq


class Dijkstra():
    def __init__(self):
        self.e = collections.defaultdict(list)

    def add(self, u, v, d):
        self.e[u].append([v, d])
        self.e[v].append([u, d])

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def search(self, s):
        """
        :param s: 始点
        :return: 始点から各点までの最短経路
        """
        d = collections.defaultdict(lambda: float('inf'))
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            for uv, ud in self.e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    heapq.heappush(q, (vd, uv))

        return d


N, M, S, T = list(map(int, input().split()))
UVAB = [list(map(int, input().split())) for i in range(M)]
graph1 = Dijkstra()
graph2 = Dijkstra()

for u, v, a, b in UVAB:
    graph1.add(u, v, a)
    graph2.add(u, v, b)

result_a = graph1.search(S)
result_b = graph2.search(T)
ans_list = [float('inf')]
for i in range(N, 0, -1):
    cur = result_a[i] + result_b[i]
    if cur > ans_list[-1]:
        cur = ans_list[-1]
    ans_list.append(cur)

for i in range(len(ans_list[1:])):
    print((10**15-ans_list[-(i+1)]))
# Original solution
N,M,S,T = map(int,input().split())
S,T = S-1,T-1
UVAB = [tuple(map(int,input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for u,v,a,b in UVAB:
    u,v = u-1,v-1
    es[u].append((v,a,b))
    es[v].append((u,a,b))

import heapq
INF = float('inf')
dy = [INF]*N
dy[S] = 0
hq = [(0,S)]
heapq.heapify(hq)
while hq:
    d,v = heapq.heappop(hq)
    for to,a,_ in es[v]:
        if d+a >= dy[to]: continue
        dy[to] = d+a
        heapq.heappush(hq, (d+a, to))
ds = [INF]*N
ds[T] = 0
hq = [(0,T)]
heapq.heapify(hq)
while hq:
    d,v = heapq.heappop(hq)
    for to,_,a in es[v]:
        if d+a >= ds[to]: continue
        ds[to] = d+a
        heapq.heappush(hq, (d+a, to))

ans = []
m = 0
for y,s in reversed(list(zip(dy,ds))):
    m = max(m, 10**15-y-s)
    ans.append(m)
ans.reverse()
print(*ans, sep='\n')


# Optimized solution
N,M,S,T = map(int,input().split())
S,T = S-1,T-1
UVAB = [tuple(map(int,input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for u,v,a,b in UVAB:
    u,v = u-1,v-1
    es[u].append((v,a,b))
    es[v].append((u,a,b))

import heapq
INF = float('inf')
cy = [INF] * N
cy[S] = 0
hq = [(0,S)]
heapq.heapify(hq)
while hq:
    c,v = heapq.heappop(hq)
    for to,a,_ in es[v]:
        if c+a >= cy[to]: continue
        cy[to] = c+a
        heapq.heappush(hq, (c+a, to))
cs = [INF] * N
cs[T] = 0
hq = [(0,T)]
heapq.heapify(hq)
while hq:
    c,v = heapq.heappop(hq)
    for to,_,b in es[v]:
        if c+b >= cs[to]: continue
        cs[to] = c+b
        heapq.heappush(hq, (c+b, to))

ans = [-1] * N
minc = INF
for i,(y,s) in reversed(list(enumerate(zip(cy,cs)))):
    minc = min(minc, y+s)
    ans[i] = 10**15 - minc
print(*ans, sep='\n')
# Original solution
import heapq
n, m, s, t = list(map(int, input().split()))


def to_v(i, j):
    return 2*i+j


N = 2*n
edges = [[]for _ in range(N)]
for _ in range(m):
    u, v, a, b = list(map(int, input().split()))
    u -= 1
    v -= 1
    edges[to_v(u, 0)].append((a, to_v(v, 0)))
    edges[to_v(v, 0)].append((a, to_v(u, 0)))
    edges[to_v(u, 1)].append((b, to_v(v, 1)))
    edges[to_v(v, 1)].append((b, to_v(u, 1)))

for u in range(n):
    edges[to_v(u, 0)].append((0, to_v(u, 1)))


def dijkstra(init_v):
    next_v = [(0, init_v)]
    INF = 10**18
    dist = [INF]*N
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in edges[v]:
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist
  

for i in range(n):
    if i != 0:
        i -= 1
        edges[to_v(i, 0)].pop()
    dist = dijkstra(to_v(s-1, 0))
    print((10**15-dist[to_v(t-1, 1)]))


# Optimized solution
import heapq
n, m, s, t = list(map(int, input().split()))
edges_yen = [[]for _ in range(n)]
edges_snuuk = [[]for _ in range(n)]
for _ in range(m):
    u, v, a, b = list(map(int, input().split()))
    edges_yen[u-1].append((a, v-1))
    edges_yen[v-1].append((a, u-1))
    edges_snuuk[u-1].append((b, v-1))
    edges_snuuk[v-1].append((b, u-1))


def dijkstra(init_v, edges):
    next_v = [(0, init_v)]
    INF = 10**18
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in edges[v]:
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


dist_yen = dijkstra(s-1, edges_yen)
dist_snuuk = dijkstra(t-1, edges_snuuk)
dist = [x+y for x, y in zip(dist_yen, dist_snuuk)]
ans = []
INF = 10**18
MIN = INF
for x in dist[::-1]:
    if x < MIN:
        MIN = x
    ans.append(MIN)
for x in ans[::-1]:
    print((10**15-x))
# Original solution
import heapq
import sys
input = sys.stdin.readline


def dijkstra(start: int, graph: list) -> list:
    """dijkstra法: 始点startから各頂点への最短距離を求める
    重み付きグラフgraphは隣接リストで与えられる
    計算量: O(|E|log|V|)
    """
    INF = float("inf")
    n = len(graph)
    distance = [INF] * n
    distance[start] = 0
    
    q = [(start, 0)]  #q = [(現在地, startからの距離)]
    while q:
        pos, dist = heapq.heappop(q)
        if distance[pos] < dist:
            continue
        distance[pos] = dist
        for next_pos, cost in graph[pos]:
            if distance[pos] + cost < distance[next_pos]:
                distance[next_pos] = distance[pos] + cost
                heapq.heappush(q, (next_pos, distance[next_pos]))
    return distance


n, m, s, t = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]

y_graph = [[] for i in range(n)]
s_graph = [[] for i in range(n)]
for u, v, a, b in info:
    u -= 1
    v -= 1
    y_graph[u].append((v, a))
    y_graph[v].append((u, a))
    s_graph[u].append((v, b))
    s_graph[v].append((u, b))

s -= 1
t -= 1
y_cost = dijkstra(s, y_graph)
s_cost = dijkstra(t, s_graph)

ans = [0]*n
for i in range(n):
    ans[i] = y_cost[i] + s_cost[i]

for i in range(n-1)[::-1]:
    ans[i] = min(ans[i], ans[i+1])

for num in ans:
    print((10**15 - num))

# Optimized solution
import heapq
import sys
input = sys.stdin.readline


def dijkstra(start: int, graph: list) -> list:
    """dijkstra法: 始点startから各頂点への最短距離を求める
    重み付きグラフgraphは隣接リストで与えられる
    計算量: O(|E|log|V|)
    """
    INF = float("inf")
    n = len(graph)
    distance = [INF] * n
    distance[start] = 0
    q = [(0, start)]  #q = [(startからの距離, 現在地)]
    while q:
        dist, pos = heapq.heappop(q)
        if distance[pos] < dist:
            continue
        for next_pos, cost in graph[pos]:
            if distance[pos] + cost < distance[next_pos]:
                distance[next_pos] = distance[pos] + cost
                heapq.heappush(q, (distance[next_pos], next_pos))
    return distance


n, m, s, t = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]

y_graph = [[] for i in range(n)]
s_graph = [[] for i in range(n)]
for i in range(m):
    u, v, a, b = info[i]
    u -= 1
    v -= 1
    y_graph[u].append((v, a))
    y_graph[v].append((u, a))
    s_graph[u].append((v, b))
    s_graph[v].append((u, b))

s -= 1
t -= 1
y_cost = dijkstra(s, y_graph)
s_cost = dijkstra(t, s_graph)

ans = [0]*n
for i in range(n):
    ans[i] = y_cost[i] + s_cost[i]

for i in range(n-1)[::-1]:
    ans[i] = min(ans[i], ans[i+1])

for num in ans:
    print((10**15 - num))