CodeEff/ECCO huggingface dataset:
# Original solution
import sys
input = sys.stdin.readline
n, m, s, t = list(map(int,input().split()))
C = [list(map(int,input().split())) for i in range(m)]

s -= 1
t -= 1

# O((V + E)log(V))
# Cは [[スタート頂点, ゴール頂点, 重み], ...] のリスト

for i in range(m):
    for j in range(2):
        C[i][j] -= 1

M = [[] for i in range(n)]
for i in range(len(C)):
    M[C[i][0]].append([C[i][1], C[i][2]])  # 無向グラフなら両方追加
    M[C[i][1]].append([C[i][0], C[i][2]])  # 無向グラフなら両方追加

N = [[] for i in range(n)]
for i in range(len(C)):
    N[C[i][0]].append([C[i][1], C[i][3]])  # 無向グラフなら両方追加
    N[C[i][1]].append([C[i][0], C[i][3]])  # 無向グラフなら両方追加

import heapq

def dijkstra(s, M):
    D = [float("inf")] * n  # 頂点0からの距離
    P = [-1] * n  # 頂点0からの最短距離において、そこの直前の頂点(経路復元に利用)
    D[s] = 0
    V = [0] * n  # その頂点のD[i]が最短距離と確定したら1
    Q = []  # 優先度付きキュー
    for v in range(n):
        heapq.heappush(Q, [D[v], v])

    le = len(Q)
    while le > 0:
        q = heapq.heappop(Q)
        u = q[1]
        du = q[0]
        if V[u] == 0:
            V[u] = 1
            le -= 1
            for i in range(len(M[u])):
                v = M[u][i][0]
                luv = M[u][i][1]
                if V[v] == 0:
                    alt = du + luv
                    if D[v] > alt:
                        D[v] = alt
                        P[v] = u
                        heapq.heappush(Q, [alt, v])
    return D, P

Ds, _ = dijkstra(s, M)
Dt, _ = dijkstra(t, N)

ANS = [0] * n

# print(Ds,Dt)

ans = float("inf")
for i in range(n-1, -1, -1):
    ans = min(ans, Ds[i] + Dt[i])
    ANS[i] = ans

for i in range(n):
    print((10**15 - ANS[i]))

# Optimized solution
import sys
input = sys.stdin.readline
n, m, s, t = list(map(int,input().split()))
C = [list(map(int,input().split())) for i in range(m)]

s -= 1
t -= 1

# O((V + E)log(V))
# Cは [[スタート頂点, ゴール頂点, 重み], ...] のリスト

M = [[] for i in range(n)]
for i in range(len(C)):
    M[C[i][0]-1].append([C[i][1]-1, C[i][2]])  # 無向グラフなら両方追加
    M[C[i][1]-1].append([C[i][0]-1, C[i][2]])  # 無向グラフなら両方追加

N = [[] for i in range(n)]
for i in range(len(C)):
    N[C[i][0]-1].append([C[i][1]-1, C[i][3]])  # 無向グラフなら両方追加
    N[C[i][1]-1].append([C[i][0]-1, C[i][3]])  # 無向グラフなら両方追加

import heapq

def dijkstra(s, M):
    D = [10**16] * n  # 頂点0からの距離
    P = [-1] * n  # 頂点0からの最短距離において、そこの直前の頂点(経路復元に利用)
    D[s] = 0
    V = [0] * n  # その頂点のD[i]が最短距離と確定したら1
    Q = []  # 優先度付きキュー
    for v in range(n):
        heapq.heappush(Q, [D[v], v])

    le = len(Q)
    while le > 0:
        q = heapq.heappop(Q)
        u = q[1]
        du = q[0]
        if V[u] == 0:
            V[u] = 1
            le -= 1
            for i in range(len(M[u])):
                v = M[u][i][0]
                luv = M[u][i][1]
                if V[v] == 0:
                    alt = du + luv
                    if D[v] > alt:
                        D[v] = alt
                        P[v] = u
                        heapq.heappush(Q, [alt, v])
    return D, P

Ds, _ = dijkstra(s, M)
Dt, _ = dijkstra(t, N)

ANS = [0] * n

# print(Ds,Dt)

ans = 10**16
for i in range(n-1, -1, -1):
    ans = min(ans, Ds[i] + Dt[i])
    ANS[i] = ans

for i in range(n):
    print((10**15 - ANS[i]))
# Original solution
from collections import defaultdict 
import sys
import heapq

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
N,M,s,t = list(map(int,input().split()))


#root[n] -> nからいけるlist
root_yen = defaultdict(set)
root_snu = defaultdict(set)


#cost[a][b] = a -> b のコスト
cost_yen = [[0 for i in range(N+1)] for j in range(N+1)]
cost_snu = [[0 for i in range(N+1)] for j in range(N+1)]


#weight[a] = start -> a のコスト 未探索->-1
weight_yen = [-1 for i in range(N+1)]
weight_snu = [-1 for i in range(N+1)]
weight_yen[s] = 0
weight_snu[t] = 0


#q = 次に探索する(確定する)もの q[0]=[w,n]
q_yen = [[0,s]]
q_snu = [[0,t]]
heapq.heapify(q_yen)
heapq.heapify(q_snu)


for i in range(M):
	u,v,a,b = list(map(int,input().split())) #
	
	root_yen[u].add(v)
	root_yen[v].add(u)
	
	root_snu[u].add(v)
	root_snu[v].add(u)
	
	cost_yen[u][v] = a
	cost_yen[v][u] = a
	cost_snu[u][v] = b
	cost_snu[v][u] = b
	
	
def search_yen (n,w_0): #nから更新 w_0:確定コスト
	global cost_yen
	global weight_yen
	global q_yen
		
	for i in list(root_yen[n]):
		w = w_0 + cost_yen[n][i]
		if weight_yen[i] == -1 or weight_yen[i] > w: #未探索orより小さい
			heapq.heappush(q_yen, [w,i])
			weight_yen[i] = w
			
def search_snu (n,w_0): #nから更新 w_0:確定コスト
	global cost_snu
	global weight_snu
	global q_snu
		
	for i in list(root_snu[n]):
		w = w_0 + cost_snu[n][i]
		if weight_snu[i] == -1 or weight_snu[i] > w: #未探索orより小さい
			heapq.heappush(q_snu, [w,i])
			weight_snu[i] = w			
			
while q_yen:
	w,n = heapq.heappop(q_yen)
	search_yen(n,w)
	
while q_snu:
	w,n = heapq.heappop(q_snu)
	search_snu(n,w)
	

finalans = float('inf')
ans_li = []

for i in range(0,N):
	ans = weight_yen[N-i] + weight_snu[N-i]
	finalans = min(finalans, ans)
	ans_li.append(finalans)
	
for i in range(N):
	print((10**15 - ans_li[N-i-1]))

# Optimized solution
from collections import defaultdict 
import sys
import heapq

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
N,M,s,t = list(map(int,input().split()))


#root[n] -> nからいけるlist
roots = defaultdict(set)

#weight[a] = start -> a のコスト 未探索->-1
weight_yen = [-1 for i in range(N+1)]
weight_snu = [-1 for i in range(N+1)]
weight_yen[s] = 0
weight_snu[t] = 0


for i in range(M):
	u,v,a,b = list(map(int,input().split())) #

	roots[u].add((v,a,b))
	roots[v].add((u,a,b))
		
	
def search_yen (n,w_0): #nから更新 w_0:確定コスト
	global weight_yen
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[1]
		if weight_yen[i] == -1 or weight_yen[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_yen[i] = w
			
def search_snu (n,w_0): #nから更新 w_0:確定コスト
	global weight_snu
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[2]
		if weight_snu[i] == -1 or weight_snu[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_snu[i] = w

#q = 次に探索する(確定する)もの q[0]=[w,n]
q = [[0,s]]
heapq.heapify(q)
			
while q:
	w,n = heapq.heappop(q)
	search_yen(n,w)
	
heapq.heappush(q, [0,t])
	
while q:
	w,n = heapq.heappop(q)
	search_snu(n,w)
	

finalans = float('inf')
ans_li = []

for i in range(0,N):
	ans = weight_yen[N-i] + weight_snu[N-i]
	finalans = min(finalans, ans)
	ans_li.append(finalans)
	
for i in range(N):
	print((10**15 - ans_li[N-i-1]))
# Original solution
from collections import defaultdict 
import sys
import heapq

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
N,M,s,t = list(map(int,input().split()))


#root[n] -> nからいけるlist
root_yen = defaultdict(set)
root_snu = defaultdict(set)


#cost[a][b] = a -> b のコスト
cost_yen = [[0 for i in range(N+1)] for j in range(N+1)]
cost_snu = [[0 for i in range(N+1)] for j in range(N+1)]


#weight[a] = start -> a のコスト 未探索->-1
weight_yen = [-1 for i in range(N+1)]
weight_snu = [-1 for i in range(N+1)]
weight_yen[s] = 0
weight_snu[t] = 0


#q = 次に探索する(確定する)もの q[0]=[w,n]
q_yen = [[0,s]]
q_snu = [[0,t]]
heapq.heapify(q_yen)
heapq.heapify(q_snu)


for i in range(M):
	u,v,a,b = list(map(int,input().split())) #
	
	root_yen[u].add(v)
	root_yen[v].add(u)
	
	root_snu[u].add(v)
	root_snu[v].add(u)
	
	cost_yen[u][v] = a
	cost_yen[v][u] = a
	cost_snu[u][v] = b
	cost_snu[v][u] = b
	
	
def search_yen (n,w_0): #nから更新 w_0:確定コスト
	global cost_yen
	global weight_yen
	global q_yen
		
	for i in list(root_yen[n]):
		w = w_0 + cost_yen[n][i]
		if weight_yen[i] == -1 or weight_yen[i] > w: #未探索orより小さい
			heapq.heappush(q_yen, [w,i])
			weight_yen[i] = w
			
def search_snu (n,w_0): #nから更新 w_0:確定コスト
	global cost_snu
	global weight_snu
	global q_snu
		
	for i in list(root_snu[n]):
		w = w_0 + cost_snu[n][i]
		if weight_snu[i] == -1 or weight_snu[i] > w: #未探索orより小さい
			heapq.heappush(q_snu, [w,i])
			weight_snu[i] = w			
			
while q_yen:
	w,n = heapq.heappop(q_yen)
	search_yen(n,w)
	
while q_snu:
	w,n = heapq.heappop(q_snu)
	search_snu(n,w)
	

finalans = float('inf')
ans_li = []

for i in range(0,N):
	ans = weight_yen[N-i] + weight_snu[N-i]
	finalans = min(finalans, ans)
	ans_li.append(finalans)
	
for i in range(N):
	print((10**15 - ans_li[N-i-1]))


# Optimized solution
from collections import defaultdict 
import sys
import heapq

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
N,M,s,t = list(map(int,input().split()))


#root[n] -> nからいけるlist
roots = defaultdict(set)

#weight[a] = start -> a のコスト 未探索->-1
weight_yen = [-1 for i in range(N+1)]
weight_snu = [-1 for i in range(N+1)]
weight_yen[s] = 0
weight_snu[t] = 0


for i in range(M):
	u,v,a,b = list(map(int,input().split())) #

	roots[u].add((v,a,b))
	roots[v].add((u,a,b))
		
	
def search_yen (n,w_0): #nから更新 w_0:確定コスト
	global weight_yen
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[1]
		if weight_yen[i] == -1 or weight_yen[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_yen[i] = w
			
def search_snu (n,w_0): #nから更新 w_0:確定コスト
	global weight_snu
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[2]
		if weight_snu[i] == -1 or weight_snu[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_snu[i] = w

#q = 次に探索する(確定する)もの q[0]=[w,n]
q = [[0,s]]
heapq.heapify(q)
			
while q:
	w,n = heapq.heappop(q)
	search_yen(n,w)
	
heapq.heappush(q, [0,t])
	
while q:
	w,n = heapq.heappop(q)
	search_snu(n,w)
	

finalans = float('inf')
ans_li = []

for i in range(0,N):
	ans = weight_yen[N-i] + weight_snu[N-i]
	finalans = min(finalans, ans)
	ans_li.append(finalans)
	
for i in range(N):
	print((10**15 - ans_li[N-i-1]))
# Original solution
from heapq import heappush, heappop

n,m,s,t = list(map(int,input().split()))
e = [[] for i in range(n+1)]
for i in range(m):
    u,v,a,b = list(map(int,input().split()))
    e[u].append((v,a,b))
    e[v].append((u,a,b))

S = [float("INF")]*(n+1)
S[s] = 0
h = []
heappush(h,[s,0])
while h:
    now,d = heappop(h)
    for nex,a,b in e[now]:
        if d+a < S[nex]:
            S[nex] = d+a
            heappush(h,[nex,d+a])
T = [float("INF")]*(n+1)
T[t] = 0
h = []
heappush(h,[t,0])
while h:
    now,d = heappop(h)
    for nex,a,b in e[now]:
        if d+b < T[nex]:
            T[nex] = d+b
            heappush(h,[nex,d+b])

ans = [0]*(n+1)
cost = 10**15
now = 0
for i in range(n,0,-1):
    now = max(now,cost-S[i]-T[i])
    ans[i] = now
for i in ans[1:]:
    print(i)

# Optimized solution
from heapq import heappush, heappop

n,m,s,t = list(map(int,input().split()))
e = [[] for i in range(n+1)]
for i in range(m):
    u,v,a,b = list(map(int,input().split()))
    e[u].append((v,a,b))
    e[v].append((u,a,b))

S = [float("INF")]*(n+1)
S[s] = 0
h = []
heappush(h,[0,s])
while h:
    d,now = heappop(h)
    for nex,a,b in e[now]:
        if d+a < S[nex]:
            S[nex] = d+a
            heappush(h,[d+a,nex])
T = [float("INF")]*(n+1)
T[t] = 0
h = []
heappush(h,[0,t])
while h:
    d,now = heappop(h)
    for nex,a,b in e[now]:
        if d+b < T[nex]:
            T[nex] = d+b
            heappush(h,[d+b,nex])

ans = [0]*(n+1)
cost = 10**15
now = 0
for i in range(n,0,-1):
    now = max(now,cost-S[i]-T[i])
    ans[i] = now
for i in ans[1:]:
    print(i)
# Original solution
from heapq import heappush, heappop

n,m,s,t = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    e[u].append((v,a,b))
    e[v].append((u,a,b))
    
def dik(s,v):
    S = [float("INF")]*(n+1)
    S[s] = 0
    h = []
    heappush(h,[0,s])
    while h:
        d,now = heappop(h)
        for nex in e[now]:
            a,b = nex[0],nex[v]
            if d+b < S[a]:
                S[a] = d+b
                heappush(h,[d+b,a])
    return S
S = dik(s,1)
T = dik(t,2)
ans = [0]*(n)
cost = 10**15
now = 0
for i in range(n-1,-1,-1):
    now = max(now,cost-S[i+1]-T[i+1])
    ans[i] = now
print(*ans,sep="\n")


# Optimized solution
from heapq import heappush as pu, heappop as po

n,m,s,t = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    e[u].append((v,a,b))
    e[v].append((u,a,b))

def dik(s,v):
    S = [float("INF")]*(n+1)
    S[s] = 0
    h = []
    pu(h,[0,s])
    while h:
        d,now = po(h)
        for nex in e[now]:
            a,b = nex[0],nex[v]
            if d+b < S[a]:
                S[a] = d+b
                pu(h,[d+b,a])
    return S[::-1]
ans = []
cost = 10**15
now = 0
for i,j in zip(dik(s,1),dik(t,2)):
    now = max(now,cost-i-j)
    ans.append(now)
print(*ans[:-1][::-1],sep="\n")
# Original solution
import heapq as hq
from collections import deque
n,m,s,t=list(map(int,input().split()))
yenLinks={}
snkLinks={}
for _ in range(m):
    u,v,a,b=list(map(int,input().split()))
    if u not in yenLinks:
        yenLinks[u]=[(v,a)]
        snkLinks[u]=[(v,b)]
    else:
        yenLinks[u].append((v,a))
        snkLinks[u].append((v,b))
    if v not in yenLinks:
        yenLinks[v]=[(u,a)]
        snkLinks[v]=[(u,b)]
    else:
        yenLinks[v].append((u,a))
        snkLinks[v].append((u,b))
#Dijkstra
INF=100000000000001
for i in range(1,n+1):
    yenDijk=[[INF,0] for _ in range(n+1)] #Distance,Determined index0 never used#
    snkDijk=[[INF,0] for _ in range(n+1)]

#yen route
pQueue=[(0,s)]
yenDijk[s]=[0,0]
hq.heapify(pQueue)

while pQueue:
    d,v = hq.heappop(pQueue)
    if yenDijk[v][1]:
        continue
    else:
        yenDijk[v][1] = 1
    for (w,D) in yenLinks[v]:
        if yenDijk[w][1]:
            continue
        else:
            if yenDijk[w][0]>yenDijk[v][0]+D:
                yenDijk[w][0] = yenDijk[v][0]+D
                hq.heappush(pQueue,(yenDijk[w][0],w))

#snuuk route
pQueue=[(0,t)]
snkDijk[t]=[0,0]
hq.heapify(pQueue)

while pQueue:
    d,v = hq.heappop(pQueue)
    if snkDijk[v][1]:
        continue
    else:
        snkDijk[v][1] = 1
    for (w,D) in snkLinks[v]:
        if snkDijk[w][1]:
            continue
        else:
            if snkDijk[w][0]>snkDijk[v][0]+D:
                snkDijk[w][0] = snkDijk[v][0]+D
                hq.heappush(pQueue,(snkDijk[w][0],w))
#OUTPUT
i = n
ans = INF
answers=[]
while i>0:
    ans = min(ans,yenDijk[i][0]+snkDijk[i][0])
    answers.append(1000000000000000-ans)
    i-=1
answers.reverse()
for ans in answers:
    print(ans)

# Optimized solution
import heapq as hq
from collections import deque
n,m,s,t=list(map(int,input().split()))
#リンク情報をつくる
yenLinks={}
snkLinks={}
for _ in range(m):
    u,v,a,b=list(map(int,input().split()))
    if u not in yenLinks:
        yenLinks[u]=[(v,a)]
        snkLinks[u]=[(v,b)]
    else:
        yenLinks[u].append((v,a))
        snkLinks[u].append((v,b))
    if v not in yenLinks:
        yenLinks[v]=[(u,a)]
        snkLinks[v]=[(u,b)]
    else:
        yenLinks[v].append((u,a))
        snkLinks[v].append((u,b))
#Dijkstra法をする関数
INF=float('inf')
def dijkstra(start,links,nodeNum):
    ans=[INF for _ in range(nodeNum+1)]
    ans[start]=0
    PQ=[(0,start)]
    hq.heapify(PQ)
    while PQ:
        (Vd,V) = hq.heappop(PQ)
        #print([V,Vd,ans[V]])
        if Vd > ans[V]:
            continue
        for (W,D) in links[V]:
            cand = ans[V] + D
            if cand < ans[W]:
                ans[W] = cand
                hq.heappush(PQ,(ans[W],W))
            #print(PQ)
    return(ans)
#Dijkstra法実行
yenKstra=dijkstra(s,yenLinks,n)
snkKstra=dijkstra(t,snkLinks,n)
#答えを求める
i=n
ans=INF
answers=[]
while i>0:
    cand = yenKstra[i]+snkKstra[i]
    ans = min(ans,cand)
    answers.append(10**15-ans)
    i-=1
answers.reverse()
#出力
for ans in answers:
    print(ans)
# Original solution
import heapq as hq
from collections import deque
n,m,s,t=list(map(int,input().split()))
#リンク情報をつくる
yenLinks={}
snkLinks={}
for _ in range(m):
    u,v,a,b=list(map(int,input().split()))
    if u not in yenLinks:
        yenLinks[u]=[(v,a)]
        snkLinks[u]=[(v,b)]
    else:
        yenLinks[u].append((v,a))
        snkLinks[u].append((v,b))
    if v not in yenLinks:
        yenLinks[v]=[(u,a)]
        snkLinks[v]=[(u,b)]
    else:
        yenLinks[v].append((u,a))
        snkLinks[v].append((u,b))
#Dijkstra法をする関数
INF=float('inf')
def dijkstra(start,links,nodeNum):
    ans=[INF for _ in range(nodeNum+1)]
    ans[start]=0
    PQ=[(0,start)]
    hq.heapify(PQ)
    while PQ:
        (Vd,V) = hq.heappop(PQ)
        #print([V,Vd,ans[V]])
        if Vd > ans[V]:
            continue
        for (W,D) in links[V]:
            cand = ans[V] + D
            if cand < ans[W]:
                ans[W] = cand
                hq.heappush(PQ,(ans[W],W))
            #print(PQ)
    return(ans)
#Dijkstra法実行
yenKstra=dijkstra(s,yenLinks,n)
snkKstra=dijkstra(t,snkLinks,n)
#答えを求める
i=n
ans=INF
answers=[]
while i>0:
    cand = yenKstra[i]+snkKstra[i]
    ans = min(ans,cand)
    answers.append(10**15-ans)
    i-=1
answers.reverse()
#出力
for ans in answers:
    print(ans)

# Optimized solution
import heapq as hq
from collections import deque
n,m,s,t=list(map(int,input().split()))
#リンク情報をつくる
yenLinks={}
snkLinks={}
for _ in range(m):
    u,v,a,b=list(map(int,input().split()))
    if u not in yenLinks:
        yenLinks[u]=[(v,a)]
        snkLinks[u]=[(v,b)]
    else:
        yenLinks[u].append((v,a))
        snkLinks[u].append((v,b))
    if v not in yenLinks:
        yenLinks[v]=[(u,a)]
        snkLinks[v]=[(u,b)]
    else:
        yenLinks[v].append((u,a))
        snkLinks[v].append((u,b))
#Dijkstra法をする関数
INF=float('inf')
def dijkstra(start,links,nodeNum):
    ans=[INF for _ in range(nodeNum+1)]
    ans[start]=0
    PQ=[(0,start)]
    hq.heapify(PQ)
    while PQ:
        (Vd,V) = hq.heappop(PQ)
        #print([V,Vd,ans[V]])
        if Vd > ans[V]:
            continue
        for (W,D) in links[V]:
            cand = ans[V] + D
            if cand < ans[W]:
                ans[W] = cand
                hq.heappush(PQ,(ans[W],W))
            #print(PQ)
    return(ans)
#Dijkstra法実行
yenKstra=dijkstra(s,yenLinks,n)
snkKstra=dijkstra(t,snkLinks,n)
#答えを求める
i=n
ans=INF
answers=deque()
while i>0:
    cand = yenKstra[i]+snkKstra[i]
    ans = min(ans,cand)
    answers.append(10**15-ans)
    i-=1
#出力
for _ in range(n):
    print((answers.pop()))
# Original solution
from heapq import heappush, heappop
from collections import defaultdict

n, m, s, t = list(map(int, input().split()))
y = 10**15


class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))


class Dijkstra(object):
    def __init__(self, graph, start):
        self.g = graph.graph

        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    heappush(self.Q, (alt, v))


yen_g = Graph()
sno_g = Graph()
for _ in range(m):
    u, v, a, b = list(map(int, input().split()))
    yen_g.add_edge(u, v, a)
    yen_g.add_edge(v, u, a)
    sno_g.add_edge(u, v, b)
    sno_g.add_edge(v, u, b)

cost = [0] * n
yen_d = Dijkstra(yen_g, s)
sno_d = Dijkstra(sno_g, t)
for i in range(1, n + 1):
    cost[i - 1] = yen_d.dist[i] + sno_d.dist[i]

for i in range(n):
    print((y - min(cost[i:])))


# Optimized solution
from heapq import heappush, heappop
from collections import defaultdict

n, m, s, t = list(map(int, input().split()))
y = 10**15


class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))


class Dijkstra(object):
    def __init__(self, graph, start):
        self.g = graph.graph

        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    heappush(self.Q, (alt, v))


yen_g = Graph()
sno_g = Graph()
for _ in range(m):
    u, v, a, b = list(map(int, input().split()))
    yen_g.add_edge(u, v, a)
    yen_g.add_edge(v, u, a)
    sno_g.add_edge(u, v, b)
    sno_g.add_edge(v, u, b)

cost = [0] * n
yen_d = Dijkstra(yen_g, s)
sno_d = Dijkstra(sno_g, t)
for i in range(1, n + 1):
    cost[i - 1] = y - (yen_d.dist[i] + sno_d.dist[i])

ans = [y] * n
ans[n - 1] = cost[n - 1]
for i in range(n - 2, -1, -1):
    ans[i] = max(ans[i + 1], cost[i])

for a in ans:
    print(a)
# Original solution
import heapq
def dijkstra(s, type=0):
    dist = [float('inf')] * N
    dist[s] = 0
    que = [(0, s)]
    heapq.heapify(que)
    while que:
        d, v = heapq.heappop(que)
        if d > dist[v]:
            continue
        for u, a, b in E[v]:
            if type != 0:
                a, b = b, a
            tmp_d = d + a
            if tmp_d < dist[u]:
                dist[u] = tmp_d
                heapq.heappush(que, (tmp_d, u))
    return dist

N, M, s, t = list(map(int, input().split()))
E = [[] for _ in range(N)]
for _ in range(M):
    u, v, a, b = list(map(int, input().split()))
    E[u-1].append((v-1, a, b))
    E[v-1].append((u-1, a, b))

dist_s = dijkstra(s-1)
dist_t = dijkstra(t-1, 1)
ans = float('inf')
idx = -1
for i in range(N):
    if idx >= i:
        print((10 ** 15 - ans))
        continue
    tmp = float('inf')
    for j in range(i, N):
        if dist_s[j] + dist_t[j] <= tmp:
            tmp = dist_s[j] + dist_t[j]
            ans = tmp
            idx = j
    print((10 ** 15 - ans))


# Optimized solution
import heapq
def dijkstra(s, neighbor):
    dist = [float('inf')] * N
    dist[s] = 0
    que = [(0, s)]
    heapq.heapify(que)
    while que:
        d, v = heapq.heappop(que)
        if d > dist[v]:
            continue
        for u, l in neighbor[v]:
            tmp_d = d + l
            if tmp_d < dist[u]:
                dist[u] = tmp_d
                heapq.heappush(que, (tmp_d, u))
    return dist

N, M, s, t = map(int, input().split())
yen = [[] for _ in range(N)]
snuuk = [[] for _ in range(N)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    yen[u-1].append((v-1, a))
    yen[v-1].append((u-1, a))
    snuuk[u-1].append((v-1, b))
    snuuk[v-1].append((u-1, b))

dist_s = dijkstra(s-1, yen)
dist_t = dijkstra(t-1, snuuk)
ans = [-1] * N
tmp = float('inf')
for i in range(N-1, -1, -1):
    if dist_s[i] + dist_t[i] < tmp:
        tmp = dist_s[i] + dist_t[i]
    ans[i] = 10 ** 15 - tmp
print(*ans, sep='\n')