CodeEff/ECCO huggingface dataset:
# Original solution
import heapq
INF = 10 ** 17
def dijkstra(s):
    #始点sから各頂点への最短距離
    d = [INF] * (n+1)
    used = [True] * (n+1) #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in graph_a[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in graph_a[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

def dijkstra1(s):
    #始点sから各頂点への最短距離
    d = [INF] * (n+1)
    used = [True] * (n+1) #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in graph_b[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in graph_b[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d


n, m, s, t = list(map(int, input().split()))
# graph作成
graph_a = {i: [] for i in range(1, n + 1)}
graph_b = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v, a, b = list(map(int, input().split()))
    graph_a[u].append([a, v])
    graph_a[v].append([a, u])
    graph_b[u].append([b, v])
    graph_b[v].append([b, u])

yen = dijkstra(s)
snu = dijkstra1(t)

cost = [0] * n
for i in range(n):
    cost[i] = (yen[i + 1] + snu[i + 1],i)

heapq.heapify(cost)
c = -1
aaa = 10 ** 15
for i in range(n):
    if c < i:
        while cost:
            nn, t = heapq.heappop(cost)
            if t >= i:
                c = t
                break
    print((aaa - nn))


# Optimized solution
import heapq
INF = 10**18
def dijkstra(s, edge, n):
    d = [INF] * n
    used = [True] * n #True: not used
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v],e[1]))
    return d
 
n, m, s, t = list(map(int, input().split()))
s -= 1
t -= 1
graph_a = [[] for _ in range(n)]
graph_b = [[] for _ in range(n)]
for i in range(m):
    u, v, a, b = list(map(int, input().split()))
    u, v = u-1, v-1
    graph_a[u].append((a, v))
    graph_a[v].append((a, u))
    graph_b[u].append((b, v))
    graph_b[v].append((b, u))
 
yen = dijkstra(s, graph_a, n)
snu = dijkstra(t, graph_b, n)

cost = [0] * n
for i in range(n):
    cost[i] = (yen[i] + snu[i],i)

heapq.heapify(cost)
c = -1
aaa = 10 ** 15
for i in range(n):
    if c < i:
        while cost:
            nn, t = heapq.heappop(cost)
            if t >= i:
                c = t
                break
    print((aaa - nn))
# Original solution
import sys
input = sys.stdin.readline
import heapq

def dijkstra(n, graph, s, yen=True):
    dist = [10**18] * n
    queue = [(s, 0)]
    dist[s] = 0
    while queue:
        v, d = heapq.heappop(queue)
        if dist[v] < d:
            continue
        for child, costa, costb in graph[v]:
            if yen:
                cost = costa
            else:
                cost = costb
            if dist[v] + cost < dist[child]:
                dist[child] = dist[v] + cost
                heapq.heappush(queue, (child, dist[child]))
    return dist

def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    graph = [[] for _ in range(n)]
    for i in range(m):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        graph[u].append((v, a, b))
        graph[v].append((u, a, b))
    s_dist = dijkstra(n, graph, s, True)
    t_dist = dijkstra(n, graph, t, False)

    cost = 10 ** 18
    ans = [0] * n
    for i in range(n-1, -1, -1):
        cost = min(cost, s_dist[i] + t_dist[i])
        ans[i] = 10 ** 15 - cost
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


# Optimized solution
import sys
input = sys.stdin.readline
from heapq import heappop, heappush
INF = 10 ** 18

def dijkstra(n, s, g, mode):
    dist = [INF] * n
    dist[s] = 0
    hq = [(0, s)]
    while hq:
        d, v = heappop(hq)
        if dist[v] < d:
            continue
        for w, *a in g[v]:
            nd = d + a[mode]
            if dist[w] > nd:
                dist[w] = nd
                heappush(hq, (nd, w))
    return dist

def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    graph = [[] for _ in range(n)]
    for i in range(m):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        graph[u].append((v, a, b))
        graph[v].append((u, a, b))
    s_dist = dijkstra(n, s, graph, 0)
    t_dist = dijkstra(n, t, graph, 1)

    cost = float("inf")
    ans = [0] * n
    for i in range(n-1, -1, -1):
        cost = min(cost, s_dist[i] + t_dist[i])
        ans[i] = 10 ** 15 - cost
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()
# Original solution
from queue import PriorityQueue as PQ

INF = float('inf')
yen = 10**15

def pcc(src, adj):
	global n
	pq = PQ()
	dist = [INF]*(n+1)
	dist[src] = 0
	pq.put([0,src])
	while not pq.empty():
		d,u = pq.get()
		for w, v in adj[u]:
			if dist[v] > dist[u] + w:
				dist[v] = dist[u] + w
				pq.put([dist[v], v])
	return dist

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

dist_s = pcc(s,adjs)
dist_t = pcc(t,adjt)



ans = [0]*(n+1)
ans[n] = dist_s[n] + dist_t[n]
for i in range(n-1,0,-1):
	ans[i] = min(ans[i+1], dist_s[i] + dist_t[i])
for i in range(1,n+1):
	print((yen-ans[i]))


# Optimized solution
import heapq

INF = float('inf')
yen = 10**15

def pcc(src, adj):
	global n
	pq = [(0,src)]
	heapq.heapify(pq)
	dist = [INF]*(n+1)
	dist[src] = 0
	while pq:
		d,u = heapq.heappop(pq)
		for w, v in adj[u]:
			if dist[v] > dist[u] + w:
				dist[v] = dist[u] + w
				heapq.heappush(pq, (dist[v], v))
	return dist

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

dist_s = pcc(s,adjs)
dist_t = pcc(t,adjt)



ans = [0]*(n+1)
ans[n] = dist_s[n] + dist_t[n]
for i in range(n-1,0,-1):
	ans[i] = min(ans[i+1], dist_s[i] + dist_t[i])
for i in range(1,n+1):
	print((yen-ans[i]))
# Original solution
import heapq
INF = float('inf')
yen = 10**15
def pcc(src, adj):
	pq = [(0,src)]
	heapq.heapify(pq)
	dist = [INF]*(n+1)
	dist[src] = 0
	while pq:
		d,u = heapq.heappop(pq)
		if d>dist[u]:continue
		for w, v in adj[u]:
			if dist[v] > dist[u] + w:
				dist[v] = dist[u] + w
				heapq.heappush(pq, (dist[v], v))
	return dist

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

dist_s = pcc(s,adjs)
dist_t = pcc(t,adjt)
ans = [0]*(n)
ans[n-1] = yen -dist_s[n] - dist_t[n]
for i in range(n-2,-1,-1):
	ans[i] = max(ans[i+1], yen - dist_s[i+1] - dist_t[i+1])
print(*ans, sep = '\n')


# 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')
# Original solution
import heapq
INF = float('inf')
yen = 10**15
def pcc(src, adj):
	pq = [(0,src)]
	heapq.heapify(pq)
	dist = [INF]*(n+1)
	dist[src] = 0
	while pq:
		d,u = heapq.heappop(pq)
		if d>dist[u]:continue
		for w, v in adj[u]:
			if dist[v] > dist[u] + w:
				dist[v] = dist[u] + w
				heapq.heappush(pq, (dist[v], v))
	return dist

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

dist_s = pcc(s,adjs)
dist_t = pcc(t,adjt)
ans = [0]*(n)
ans[n-1] = yen -dist_s[n] - dist_t[n]
for i in range(n-2,-1,-1):
	ans[i] = max(ans[i+1], yen - dist_s[i+1] - dist_t[i+1])
print(*ans, sep = '\n')


# Optimized solution
import heapq
INF = float('inf')
yen = 10**15
def pcc(src, adj):
	pq = [(0,src)]
	heapq.heapify(pq)
	dist = [INF]*n
	dist[src] = 0
	while pq:
		d,u = heapq.heappop(pq)
		if d>dist[u]:continue
		for w, v in adj[u]:
			if dist[v] > dist[u] + w:
				dist[v] = dist[u] + w
				heapq.heappush(pq, (dist[v], v))
	return dist

n,m,s,t = map(int, input().split())
s,t = s-1,t-1
adjs = [[] for _ in range(n)]
adjt = [[] for _ in range(n)]
for _ in range(m):
	u,v,a,b = map(int, input().split())
	u,v = u-1, v-1
	adjs[u].append((a,v))
	adjs[v].append((a,u))
	adjt[u].append((b,v))
	adjt[v].append((b,u))

dist_s = pcc(s,adjs)
dist_t = pcc(t,adjt)
ans = [0]*(n)
ans[n-1] = yen -dist_s[n-1] - dist_t[n-1]
for i in range(n-2,-1,-1):
	ans[i] = max(ans[i+1], yen - dist_s[i] - dist_t[i])
print(*ans, sep = '\n')
# Original solution
import heapq
INF = float('inf')
yen = 10**15
def pcc(src, adj):
	pq = [(0,src)]
	heapq.heapify(pq)
	dist = [INF]*n
	dist[src] = 0
	while pq:
		d,u = heapq.heappop(pq)
		if d>dist[u]:continue
		for w, v in adj[u]:
			if dist[v] > dist[u] + w:
				dist[v] = dist[u] + w
				heapq.heappush(pq, (dist[v], v))
	return dist

n,m,s,t = map(int, input().split())
s,t = s-1,t-1
adjs = [[] for _ in range(n)]
adjt = [[] for _ in range(n)]
for _ in range(m):
	u,v,a,b = map(int, input().split())
	u,v = u-1, v-1
	adjs[u].append((a,v))
	adjs[v].append((a,u))
	adjt[u].append((b,v))
	adjt[v].append((b,u))

dist_s = pcc(s,adjs)
dist_t = pcc(t,adjt)
ans = [0]*(n)
ans[n-1] = yen -dist_s[n-1] - dist_t[n-1]
for i in range(n-2,-1,-1):
	ans[i] = max(ans[i+1], yen - dist_s[i] - dist_t[i])
print(*ans, sep = '\n')


# Optimized solution
import heapq

def pcc(src, adj):
	pq = [(0,src)]
	dist = [float('inf')]*n
	dist[src] = 0
	heapq.heapify(pq)
	while pq:
		d, u = heapq.heappop(pq)
		for w, v in adj[u]:
			if dist[v] > dist[u] + w:
				dist[v] = dist[u] + w
				heapq.heappush(pq, (dist[v], v))
	return dist

n,m,s,t = map(int,input().split())
s,t = s-1,t-1
adjs = [[] for _ in range(n)]
adjt = [[] for _ in range(n)]
for _ in range(m):
	u,v,a,b = map(int, input().split())
	u,v = u-1,v-1
	adjs[u].append((a,v))
	adjs[v].append((a,u))
	adjt[u].append((b,v))
	adjt[v].append((b,u))

dist_s = pcc(s, adjs)
dist_t = pcc(t, adjt)

ans = [0]*n
ans[n-1] = 10**15 - dist_s[n-1]-dist_t[n-1]
for i in range(n-2,-1,-1):
	ans[i] = max(ans[i+1], 10**15 - dist_s[i] - dist_t[i])
print(*ans, sep = "\n")
# Original solution
def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d


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

INF = float('inf')

cost_yen = [[INF for i in range(n)] for j in range(n)]
cost_snuuk = [[INF for i in range(n)] for j in range(n)]

for train in trains:
    u, v, a, b = train
    cost_yen[u-1][v-1] = a
    cost_yen[v-1][u-1] = a
    cost_snuuk[u-1][v-1] = b
    cost_snuuk[v-1][u-1] = b

d_yen = dijkstra(s-1, n, m, cost_yen)
d_snuuk = dijkstra(t-1, n, m, cost_snuuk)

for i in range(n):
    cost_sum = [x+y for x, y in zip(d_yen[i:], d_snuuk[i:])]
    print((10**15 - min(cost_sum)))



# Optimized solution
import sys

def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

input = sys.stdin.readline

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

INF = float('inf')

cost_yen = [[INF for i in range(n)] for j in range(n)]
cost_snuuk = [[INF for i in range(n)] for j in range(n)]

for train in trains:
    u, v, a, b = train
    cost_yen[u-1][v-1] = a
    cost_yen[v-1][u-1] = a
    cost_snuuk[u-1][v-1] = b
    cost_snuuk[v-1][u-1] = b

d_yen = dijkstra(s-1, n, m, cost_yen)
d_snuuk = dijkstra(t-1, n, m, cost_snuuk)

for i in range(n):
    cost_sum = [x+y for x, y in zip(d_yen[i:], d_snuuk[i:])]
    print((10**15 - min(cost_sum)))
# Original solution
from heapq import heapify,heappop,heappush
N,M,s,t=list(map(int,input().split()))
Graph1=[set() for i in range(N)]
Graph2=[set() for i in range(N)]
inf=float("inf")
for i in range(M):
  u,v,a,b=list(map(int,input().split()))
  Graph1[u-1].add((a,v-1))
  Graph1[v-1].add((a,u-1))
  Graph2[u-1].add((b,v-1))
  Graph2[v-1].add((b,u-1))
  
def dijkstra(s,n,links):
  cost=[inf]*n
  visited=[False]*n
  visited[s]=True
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    visited[hp]=True
    for c,p in links[hp]:
      if not visited[p]:
        if c+hc<=cost[p]:
          cost[p]=c+hc
          heappush(heap,(cost[p],p))
  return cost
 
cost1=dijkstra(s-1,N,Graph1)
cost2=dijkstra(t-1,N,Graph2)

ans=[0]*N
a=inf
for i in range(N)[::-1]:
  a=min(a,cost1[i]+cost2[i])
  ans[i]=10**15-a
for i in ans:
  print(i)

# Optimized solution
from heapq import heapify,heappop,heappush
N,M,s,t=list(map(int,input().split()))
Graph1=[set() for i in range(N)]
Graph2=[set() for i in range(N)]
inf=float("inf")
for i in range(M):
  u,v,a,b=list(map(int,input().split()))
  Graph1[u-1].add((a,v-1))
  Graph1[v-1].add((a,u-1))
  Graph2[u-1].add((b,v-1))
  Graph2[v-1].add((b,u-1))
  
def dijkstra(s,n,links):
  cost=[inf]*n
  visited=[False]*n
  cost[s]=0
  heap=[(0,s)]
  heapify(heap)
  while heap:
    hc,hp=heappop(heap)
    if not visited[hp]:
      visited[hp]=True
      for c,p in links[hp]:
        if not visited[p]:
          if c+hc<=cost[p]:
            cost[p]=c+hc
            heappush(heap,(cost[p],p))
  return cost
 
cost1=dijkstra(s-1,N,Graph1)
cost2=dijkstra(t-1,N,Graph2)

ans=[0]*N
a=inf
for i in range(N)[::-1]:
  a=min(a,cost1[i]+cost2[i])
  ans[i]=10**15-a
for i in ans:
  print(i)
# Original solution
from collections import defaultdict
from heapq import heapify, heappop
import heapq
n,m,s,t =list(map(int,input().split()))

MAX_VAL = 10**20
uvab =  [list(map(int,input().split())) for _ in range(m)]
jpy_cost = defaultdict(lambda :defaultdict(lambda :MAX_VAL))
snuke_cost = defaultdict(lambda :defaultdict(lambda :MAX_VAL))


for u,v,a,b in uvab:
    u=u-1
    v=v-1
    jpy_cost[u][v] = a
    jpy_cost[v][u] =a
    snuke_cost[u][v]=b
    snuke_cost[v][u]=b


# Dijktra's shortest path algorithm. Prints the path from source to target.


def dijkstra(adj, source):
    INF = MAX_VAL
    dist = [INF for x in range(n)]
    dist[source] = 0
    PQ = []
    heapq.heappush(PQ, [dist[source], source])

    while (PQ):
        u_dist,u_id = heapq.heappop(PQ)  # u is a tuple [u_dist, u_id]
        if u_dist == dist[u_id]:
            for v in adj[u_id]:
                w_uv = adj[u_id][v]
                if dist[u_id] + w_uv < dist[v]:
                    dist[v] = dist[u_id] + w_uv
                    heapq.heappush(PQ, [dist[v], v])
    return dist


jpy_dijk =  dijkstra(jpy_cost,s-1)
snuke_dijk = dijkstra(snuke_cost,t-1)
#
# print(s,t)
# print(jpy_dijk)
# print(snuke_dijk)
# print([jpy_dijk[i]+snuke_dijk[i] for i in range(n)])

#ord n
res = []
min_val = MAX_VAL
for i in reversed(list(range(n))):
    #都市  i で両替
    val = jpy_dijk[i]+ snuke_dijk[i]
    assert val < MAX_VAL
    min_val=min(min_val,val)
    res.append(min_val)
#ord n
for x in reversed(res):
    print((10**15-  x))


# Optimized solution
from collections import defaultdict
from heapq import heapify, heappop
import heapq
n,m,s,t =list(map(int,input().split()))

MAX_VAL = 10**20
uvab =  [list(map(int,input().split())) for _ in range(m)]
jpy_cost = defaultdict(dict)
snuke_cost = defaultdict(dict)


for u,v,a,b in uvab:
    u=u-1
    v=v-1
    jpy_cost[u][v] = a
    jpy_cost[v][u] =a
    snuke_cost[u][v]=b
    snuke_cost[v][u]=b


# Dijktra's shortest path algorithm. Prints the path from source to target.


def dijkstra(adj, source):
    INF = MAX_VAL
    dist = [INF for x in range(n)]
    dist[source] = 0
    PQ = []
    heapq.heappush(PQ, [dist[source], source])

    while (PQ):
        u_dist,u_id = heapq.heappop(PQ)  # u is a tuple [u_dist, u_id]
        if u_dist == dist[u_id]:
            for v in adj[u_id]:
                w_uv = adj[u_id][v]
                if dist[u_id] + w_uv < dist[v]:
                    dist[v] = dist[u_id] + w_uv
                    heapq.heappush(PQ, [dist[v], v])
    return dist


jpy_dijk =  dijkstra(jpy_cost,s-1)
snuke_dijk = dijkstra(snuke_cost,t-1)
#
# print(s,t)
# print(jpy_dijk)
# print(snuke_dijk)
# print([jpy_dijk[i]+snuke_dijk[i] for i in range(n)])

#ord n
res = []
min_val = MAX_VAL
for i in reversed(list(range(n))):
    #都市  i で両替
    val = jpy_dijk[i]+ snuke_dijk[i]
    assert val < MAX_VAL
    min_val=min(min_val,val)
    res.append(min_val)
#ord n
for x in reversed(res):
    print((10**15-  x))
# Original solution
'''
1つの始点から全頂点への最短距離を求めるアルゴリズム
辺の数E,頂点の数Vに対し、O((E+V)log(V))
edge[u]=[(d1, v1), (d2, v2), ...]が頂点uと頂点viに距離diの辺があることを表す隣接リストが入力
無向グラフにて検証済み。有効グラフのたぶんいけるので確認したらここを書き換えて欲しい。
'''

from heapq import heappush, heappop

INF = 10**15
 
def dijkstra(s, edges):
    que = []
    d = [INF] * n
    d[s] = 0
    heappush(que, (0, s))

    while len(que) > 0:
        (c, v) = heappop(que)
        if d[v] < c:
            continue
        for (cc, w) in edges[v]:
            if d[w] > d[v] + cc:
                d[w] = d[v] + cc
                heappush(que, (d[w], w))

    return d

n, m, s, t = list(map(int, input().split()))
s, t = s-1, t-1
yen_edge = [[] for i in range(n)]
snook_edge = [[] for i in range(n)]
for i in range(m):
    ui, vi, ai, bi = list(map(int, input().split()))
    ui, vi = vi-1, ui-1
    yen_edge[ui].append((ai, vi))
    yen_edge[vi].append((ai, ui))
    snook_edge[ui].append((bi, vi))
    snook_edge[vi].append((bi, ui))

distance_yen = dijkstra(s, yen_edge)
distance_snook = dijkstra(t, snook_edge)

ans_lst = [0 for i in range(n)]
temp_min = 10**15
for i in range(n)[::-1]:
    now = distance_yen[i] + distance_snook[i]
    temp_min = min(temp_min, now)
    ans_lst[i] = 10**15 - temp_min

for i in range(n):
    print((ans_lst[i]))

# Optimized solution
'''
1つの始点から全頂点への最短距離を求めるアルゴリズム
辺の数E,頂点の数Vに対し、O((E+V)log(V))
edge[u]=[(d1, v1), (d2, v2), ...]が頂点uと頂点viに距離diの辺があることを表す隣接リストが入力
無向グラフにて検証済み。有効グラフのたぶんいけるので確認したらここを書き換えて欲しい。
'''

from heapq import heappush, heappop

INF = 10**15
 
def dijkstra(s, edges):
    n = len(edges)
    que = []
    d = [INF] * n
    d[s] = 0
    heappush(que, (0, s))

    while len(que) > 0:
        (c, v) = heappop(que)
        if d[v] < c:
            continue
        for (cc, w) in edges[v]:
            if d[w] > d[v] + cc:
                d[w] = d[v] + cc
                heappush(que, (d[w], w))

    return d

n, m, s, t = list(map(int, input().split()))
s, t = s-1, t-1
yen_edge = [[] for i in range(n)]
snook_edge = [[] for i in range(n)]
for i in range(m):
    ui, vi, ai, bi = list(map(int, input().split()))
    ui, vi = vi-1, ui-1
    yen_edge[ui].append((ai, vi))
    yen_edge[vi].append((ai, ui))
    snook_edge[ui].append((bi, vi))
    snook_edge[vi].append((bi, ui))

distance_yen = dijkstra(s, yen_edge)
distance_snook = dijkstra(t, snook_edge)

ans_lst = [0 for i in range(n)]
temp_min = 10**15
for i in range(n)[::-1]:
    now = distance_yen[i] + distance_snook[i]
    temp_min = min(temp_min, now)
    ans_lst[i] = 10**15 - temp_min

for i in range(n):
    print((ans_lst[i]))
# Original solution
import heapq
from itertools import accumulate
inf = float('inf')

def dijkstra(ad_lst, n, s):
    costs = [inf for i in range(n+1)]
    costs[s], Q = 0, []
    heapq.heappush(Q, [costs[s], s])

    while(Q != []):
        c, u = heapq.heappop(Q)
        for v, c in ad_lst[u]:
            if costs[u] + c < costs[v]:
                heapq.heappush(Q, [costs[u] + c, v])
                costs[v] = costs[u] + c

    return costs

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

route_y = {i: [] for i in range(n+1)}
route_s = {i: [] for i in range(n+1)}
for i in range(m):
    u, v, a, b = map(int, input().split())
    route_y[u].append([v,a])
    route_y[v].append([u,a])
    route_s[u].append([v,b])
    route_s[v].append([u,b])

cost_y = dijkstra(route_y, n, s)
cost_s = dijkstra(route_s, n, t)
result = list(accumulate([y+s for y,s in zip(cost_y, cost_s)][::-1], min))
yen = 10**15
[print(yen-result[i]) for i in range(n-1, -1, -1)]


# Optimized solution
import heapq
from itertools import accumulate
inf = float('inf')

def dijkstra(ad_lst, n, s):
    costs = [inf for i in range(n+1)]
    costs[s], Q = 0, []
    heapq.heappush(Q, [costs[s], s])

    while(Q != []):
        c, u = heapq.heappop(Q)
        for v, c in ad_lst[u].items():
            if costs[u] + c < costs[v]:
                heapq.heappush(Q, [costs[u] + c, v])
                costs[v] = costs[u] + c

    return costs

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

route_y = {i: {} for i in range(n+1)}
route_s = {i: {} for i in range(n+1)}
for i in range(m):
    u, v, a, b = map(int, input().split())
    route_y[u][v] = a
    route_y[v][u] = a
    route_s[u][v] = b
    route_s[v][u] = b

cost_y = dijkstra(route_y, n, s)
cost_s = dijkstra(route_s, n, t)
result = list(accumulate([y+s for y,s in zip(cost_y, cost_s)][::-1], min))
yen = 10**15
[print(yen-result[i]) for i in range(n-1, -1, -1)]