CodeEff/ECCO huggingface dataset:
# Original solution
import sys
from collections import defaultdict as dd
import heapq
input = sys.stdin.readline
n, m, s, t = list(map(int, input().split()))
e = dd(list)
money = 10 ** 15
for _ in range(m):
  u, v, a, b = list(map(int, input().split()))
  e[u].append((v, a))
  e[v].append((u, a))
  e[u + n].append((v + n, b))
  e[v + n].append((u + n, b))
"""
for i in range(1, n + 1):
  e[i].append((i + n, 0))
"""
class dijkstra:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    vis = set()
    d[s] = 0
    h = [s]
    while not t in vis and len(h):
      v = heapq.heappop(h)
      v1 = v % (10 ** 15)
      v0 = v // (10 ** 15)
      if v1 in vis: continue
      vis.add(v1)
      for p in self.e[v1]:
        d[p[0]] = min(d[p[0]], d[v1] + p[1])
        if p[0] in vis: continue
        heapq.heappush(h, d[p[0]] * (10 ** 15) + p[0])
    return d
d = dijkstra(2 * n + 1, e)
x = d.path(s, 2 * n + 1)
y = d.path(t + n, 2 * n + 1)
#print(x)
#print(y)
paths = [float("inf")] * (n + 1)
minpaths = [float("inf")] * (n + 1)
for i in range(1, n + 1):
  paths[i] = x[i] + y[n + i]
#print(paths)
minpaths[-1] = paths[-1]
for i in range(n - 1, -1, -1):
  minpaths[i] = min(minpaths[i + 1], paths[i])
#print(minpaths)
for i in range(1, n + 1):
  print((money - minpaths[i]))

# Optimized solution
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M, s, t = list(map(int, input().split()))
e = dd(list)
ee = dd(list)
for i in range(M):
  u, v, a, b = list(map(int, input().split()))
  e[u].append((v, a))
  e[v].append((u, a))
  ee[u].append((v, b))
  ee[v].append((u, b))

import heapq
class dijkstra:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    vis = set()
    d[s] = 0
    h = [s]
    while not t in vis and len(h):
      v = heapq.heappop(h)
      v1 = v % (10 ** 10)
      v0 = v // (10 ** 10)
      if v1 in vis: continue
      vis.add(v1)
      for p in self.e[v1]:
        d[p[0]] = min(d[p[0]], d[v1] + p[1])
        if p[0] in vis: continue
        heapq.heappush(h, d[p[0]] * (10 ** 10) + p[0])
    return d
dij = dijkstra(N, e)
edij = dijkstra(N, ee)
p = dij.path(s, 0)
revp = edij.path(t, 0)
mny = pow(10, 15)
table = [0] * (N + 1)
for x in range(1, N + 1):
  table[x] = mny - p[x] - revp[x]
csmx = [0] * (N + 1)

for i in range(N, 0, -1): csmx[i - 1] = max(csmx[i - 1], table[i], csmx[i])
for i in range(N): print((csmx[i]))
# Original solution
import heapq


def dijkstra(adj, start):
    ans = [float("inf")] * len(adj)
    q = [(0, start)]
    while len(q):
        cost, node = heapq.heappop(q)
        if cost > ans[node]:
            continue
        ans[node] = cost
        for nxt in adj[node]:
            heapq.heappush(q, (cost + adj[node][nxt], nxt))
    return ans


def main():
    n, m, s, t = list(map(int, input().split()))
    adj1 = [{} for _ in range(n)]
    adj2 = [{} for _ in range(n)]
    for _ in range(m):
        u, v, a, b = list(map(int, input().split()))
        adj1[u-1][v-1] = a
        adj1[v-1][u-1] = a
        adj2[u-1][v-1] = b
        adj2[v-1][u-1] = b
    d1 = dijkstra(adj1, s-1)
    d2 = dijkstra(adj2, t-1)
    ans = [float("inf")] * n
    ans[n-1] = d1[n-1] + d2[n-1]
    for i in range(n-2, -1, -1):
        ans[i] = min(d1[i] + d2[i], ans[i+1])
    for i in range(n):
        print((10**15 - ans[i]))


if __name__ == "__main__":
    main()


# Optimized solution
from heapq import heappush, heappop


def dijkstra(N, adj, start=0):
    ans = [float("inf")] * N
    q = [(0, start)]
    while len(q):
        cost, i = heappop(q)
        if ans[i] <= cost:
            continue
        ans[i] = cost
        for nxt in adj[i]:
            if ans[nxt] == float("inf"):
                heappush(q, (cost + adj[i][nxt], nxt))
    return ans


def main():
    n, m, s, t = list(map(int, input().split()))
    adj1 = [{} for _ in range(n)]
    adj2 = [{} for _ in range(n)]
    for _ in range(m):
        u, v, a, b = list(map(int, input().split()))
        adj1[u-1][v-1] = a
        adj1[v-1][u-1] = a
        adj2[u-1][v-1] = b
        adj2[v-1][u-1] = b
    d1 = dijkstra(n, adj1, s-1)
    d2 = dijkstra(n, adj2, t-1)
    ans = [float("inf")] * n
    ans[n-1] = d1[n-1] + d2[n-1]
    for i in range(n-2, -1, -1):
        ans[i] = min(d1[i] + d2[i], ans[i+1])
    for i in range(n):
        print((10**15 - ans[i]))


if __name__ == "__main__":
    main()
# Original solution
from collections import defaultdict
import heapq
n,m,s,t=list(map(int, input().strip().split()))
links_y=defaultdict(list)
links_s=defaultdict(list)
for i in range(m):
    u,v,a,b=list(map(int, input().strip().split()))
    links_y[u-1].append((v-1,a))
    links_y[v-1].append((u-1,a))
    links_s[u-1].append((v-1,b))
    links_s[v-1].append((u-1,b))

def dijkstra(frm, links):
    dist=[float('inf')]*n
    dist[frm]=0
    Q=[(0,frm)]
    heapq.heapify(Q)
    while Q:
        d,u = heapq.heappop(Q)
        for v,dd in links[u]:
            if dist[v]> d+dd:
                dist[v]=dd+d
                heapq.heappush(Q,(dist[v],v))
    return dist
yen_cost=dijkstra(s-1,links_y)
snk_cost=dijkstra(t-1,links_s)
sumyensnk=[i+j for i,j in zip(yen_cost,snk_cost)]
min_snk=[float('inf')]*n
tmp=float('inf')
for i in range(n)[::-1]:
    min_snk[i] = min(sumyensnk[i],tmp)
    tmp = min_snk[i]
money=10**15
for sumsnk in min_snk:
    print((money-sumsnk))

# Optimized solution
import heapq
n,m,s,t=list(map(int, input().strip().split()))
links_y=[[]for i in range(n) ]
links_s=[[]for i in range(n) ]
INF=float('inf')
for i in range(m):
    u,v,a,b=list(map(int, input().strip().split()))
    links_y[u-1].append((v-1,a))
    links_y[v-1].append((u-1,a))
    links_s[u-1].append((v-1,b))
    links_s[v-1].append((u-1,b))

def dijkstra(frm, links):
    dist=[INF]*n
    dist[frm]=0
    Q=[(0,frm)]
    heapq.heapify(Q)
    while Q:
        d,u = heapq.heappop(Q)
        for v,dd in links[u]:
            if dist[v]> d+dd:
                dist[v]=dd+d
                heapq.heappush(Q,(dist[v],v))
    return dist
yen_cost=dijkstra(s-1,links_y)
snk_cost=dijkstra(t-1,links_s)
sumyensnk=[i+j for i,j in zip(yen_cost,snk_cost)]
min_snk=[INF]*n
tmp=INF
for i in range(n)[::-1]:
    min_snk[i] = min(sumyensnk[i],tmp)
    tmp = min_snk[i]
money=10**15
for sumsnk in min_snk:
    print((money-sumsnk))
# Original solution
from heapq import heappush, heappop
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    inf = float('inf')
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist

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

g_a = [[] for i in range(n)]
g_b = [[] for i in range(n)]

for i in range(m):
    u,v,a,b = list(map(int,input().split()))
    g_a[u-1].append((a,v-1))
    g_a[v-1].append((a,u-1))
    g_b[u-1].append((b,v-1))
    g_b[v-1].append((b,u-1))

d_a = dijkstra(g_a,n,s-1)
d_b = dijkstra(g_b,n,t-1)

d = []
for i in range(n):
    d.append(d_a[i]+d_b[i])

d.reverse()

for i in range(n):
    print((10**15-min(d)))
    d.pop()

# Optimized solution
from heapq import heappush, heappop
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    inf = float('inf')
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist

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

g_a = [[] for i in range(n)]
g_b = [[] for i in range(n)]

for i in range(m):
    u,v,a,b = list(map(int,input().split()))
    g_a[u-1].append((a,v-1))
    g_a[v-1].append((a,u-1))
    g_b[u-1].append((b,v-1))
    g_b[v-1].append((b,u-1))

d_a = dijkstra(g_a,n,s-1)
d_b = dijkstra(g_b,n,t-1)

d = []
for i in range(n):
    d.append(d_a[i]+d_b[i])

d.reverse()
ans = []
m = float('inf')
for i in range(n):
    m = min(m,d[i])
    ans.append(10**15-m)
ans.reverse()

for i in range(n):
    print((ans[i]))
# Original solution
import sys
input = sys.stdin.readline
from collections import defaultdict, deque
from itertools import accumulate
n,m,s,t= list(map(int,input().split()))
uvab = [list(map(int,input().split())) for i in range(m)]

g = defaultdict(list)
c = {}
for i in range(1,n+1):
    g[i].append(n+i)
    c[(i,n+i)] = 0
for u,v,a,b in uvab:
    g[u].append(v)
    g[v].append(u)
    g[n+u].append(n+v)
    g[n+v].append(n+u)
    c[(u,v)] = a
    c[(v,u)] = a
    c[(n+u,n+v)] = b
    c[(n+v,n+u)] = b

inf = 10**15
ds2t = [inf for i in range(2*n+1)]
ds2t[s] = 0

dq = deque([s])
while dq:
    v = dq.popleft()
    for nv in g[v]:
        if ds2t[nv] > ds2t[v] + c[(v,nv)]:
            ds2t[nv] = ds2t[v] + c[(v,nv)]
            dq.append(nv)


dt2s = [inf for i in range(2*n+1)]
dt2s[n+t] = 0

dq = deque([n+t])
while dq:
    v = dq.popleft()
    for nv in g[v]:
        if dt2s[nv] > dt2s[v] + c[(v,nv)]:
            dt2s[nv] = dt2s[v] + c[(v,nv)]
            dq.append(nv)

ds = []
for i in range(1,n+1):
    ds.append(ds2t[i] + dt2s[n+i])

ds = accumulate(ds[::-1], min)

for d in reversed(list(ds)): 
    print((10**15-d))




# Optimized solution
import sys
input = sys.stdin.readline
from collections import defaultdict, deque
from itertools import accumulate
n,m,s,t= list(map(int,input().split()))
uvab = [list(map(int,input().split())) for i in range(m)]

g = defaultdict(list)
c = {}
'''
for i in range(1,n+1):
    g[i].append(n+i)
    c[(i,n+i)] = 0
    '''
for u,v,a,b in uvab:
    g[u].append(v)
    g[v].append(u)
    g[n+u].append(n+v)
    g[n+v].append(n+u)
    c[(u,v)] = a
    c[(v,u)] = a
    c[(n+u,n+v)] = b
    c[(n+v,n+u)] = b

inf = 10**15
ds2t = [inf for i in range(2*n+1)]
ds2t[s] = 0

dq = deque([s])
while dq:
    v = dq.popleft()
    for nv in g[v]:
        if ds2t[nv] > ds2t[v] + c[(v,nv)]:
            ds2t[nv] = ds2t[v] + c[(v,nv)]
            dq.append(nv)


dt2s = [inf for i in range(2*n+1)]
dt2s[n+t] = 0

dq = deque([n+t])
while dq:
    v = dq.popleft()
    for nv in g[v]:
        if dt2s[nv] > dt2s[v] + c[(v,nv)]:
            dt2s[nv] = dt2s[v] + c[(v,nv)]
            dq.append(nv)

ds = []
for i in range(1,n+1):
    ds.append(ds2t[i] + dt2s[n+i])

ds = accumulate(ds[::-1], min)

for d in reversed(list(ds)): 
    print((10**15-d))
# Original solution
import heapq
import sys
n, m, s, t = [int(i) for i in input().split()]
s -= 1
t -= 1
snuuk_dict = dict()
yen_dict = dict()
snuuk_que = []
yen_que = []
for i in range(m):
    u, v, a, b = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    if snuuk_dict.get(u) is None:
        snuuk_dict[u] = []
        yen_dict[u] = []
    if snuuk_dict.get(v) is None:
        snuuk_dict[v] = []
        yen_dict[v] = []
    snuuk_dict[u].append([b, u, v])
    snuuk_dict[v].append([b, v, u])
    yen_dict[u].append([a, u, v])
    yen_dict[v].append([a, v, u])

for i in snuuk_dict[t]:
    heapq.heappush(snuuk_que, i)
for i in yen_dict[s]:
    heapq.heappush(yen_que, i)
snuuk_ls = [-1 for i in range(n)]
yen_ls = [-1 for i in range(n)]
yen_ls[s] = 0
snuuk_ls[t] = 0
while len(yen_que) > 0:
    a, u, v = heapq.heappop(yen_que)
    if yen_ls[v] != -1:
        continue
    yen_ls[v] = a
    for i in yen_dict[v]:
        heapq.heappush(yen_que, [i[0] + yen_ls[v], i[1], i[2]])
while len(snuuk_que) > 0:
    b, v, u = heapq.heappop(snuuk_que)
    if snuuk_ls[u] != -1:
        continue
    snuuk_ls[u] = b
    for i in snuuk_dict[u]:
        heapq.heappush(snuuk_que,  [i[0] + snuuk_ls[u], i[1], i[2]])
sum_ls = [10** 15 - (i + j) for i, j in zip(snuuk_ls, yen_ls)]
for i in range(n):
    print((max(sum_ls[i:])))

# Optimized solution
import heapq
import sys
n, m, s, t = [int(i) for i in input().split()]
s -= 1
t -= 1
snuuk_dict = dict()
yen_dict = dict()
snuuk_que = []
yen_que = []
for i in range(m):
    u, v, a, b = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    if snuuk_dict.get(u) is None:
        snuuk_dict[u] = []
        yen_dict[u] = []
    if snuuk_dict.get(v) is None:
        snuuk_dict[v] = []
        yen_dict[v] = []
    snuuk_dict[u].append([b, u, v])
    snuuk_dict[v].append([b, v, u])
    yen_dict[u].append([a, u, v])
    yen_dict[v].append([a, v, u])

for i in snuuk_dict[t]:
    heapq.heappush(snuuk_que, i)
for i in yen_dict[s]:
    heapq.heappush(yen_que, i)
snuuk_ls = [-1 for i in range(n)]
yen_ls = [-1 for i in range(n)]
yen_ls[s] = 0
snuuk_ls[t] = 0
while len(yen_que) > 0:
    a, u, v = heapq.heappop(yen_que)
    if yen_ls[v] != -1:
        continue
    yen_ls[v] = a
    for i in yen_dict[v]:
        if yen_ls[i[2]] == -1:
            heapq.heappush(yen_que, [i[0] + yen_ls[v], i[1], i[2]])
while len(snuuk_que) > 0:
    b, v, u = heapq.heappop(snuuk_que)
    if snuuk_ls[u] != -1:
        continue
    snuuk_ls[u] = b
    for i in snuuk_dict[u]:
        if snuuk_ls[i[2]] == -1:
            heapq.heappush(snuuk_que,  [i[0] + snuuk_ls[u], i[1], i[2]])
sum_ls = [10** 15 - (i + j) for i, j in zip(snuuk_ls, yen_ls)]
_max = 0
for i in range(n):
    _max = sum_ls[-1-i] if sum_ls[-1-i] > _max else _max
    sum_ls[-i-1] = _max
for i in range(n):
    print((sum_ls[i]))
# Original solution
import sys
from collections import namedtuple
from heapq import heappush, heappop

INF = sys.maxsize

P = namedtuple('P', 'cost v')
Edage = namedtuple('Edge', 'to cost')

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

s, t = s - 1, t - 1

# 円とスヌークそれぞれグラフを構成する
Yen = [[] for _ in range(n)]
Snuuk = [[] for _ in range(n)]

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

  
def min_costs(graph, start):
  costs = [INF] * n
  costs[start] = 0
  
  q = [P(0, start)]
  
  while q:
    cost, v = heappop(q)
    if cost > costs[v]:
      continue
    for to, cost in graph[v]:
      if costs[to] > costs[v] + cost:
        costs[to] = costs[v] + cost
        heappush(q, P(costs[to], to))        
        
  return costs
  
total_costs = [
  min_costs(Yen, s)[i] + min_costs(Snuuk, t)[i] 
  for i in range(n)
]

# 両替所が閉鎖されていく
for i in range(n - 1, 0, -1):
  total_costs[i - 1] = min(total_costs[i - 1], total_costs[i])
                      
    
for i in range(n):
  print((10 ** 15 - total_costs[i]))
  
  

# Optimized solution
import sys
from collections import namedtuple
from heapq import heappush, heappop

INF = sys.maxsize

P = namedtuple('P', 'cost v')
Edage = namedtuple('Edge', 'to cost')

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

s, t = s - 1, t - 1

# 円とスヌークそれぞれグラフを構成する
Yen = [[] for _ in range(n)]
Snuuk = [[] for _ in range(n)]

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

  
def min_costs(graph, start):
  costs = [INF] * n
  costs[start] = 0
  
  q = [P(0, start)]
  
  while q:
    cost, v = heappop(q)
    if cost > costs[v]:
      continue
    for to, cost in graph[v]:
      if costs[to] > costs[v] + cost:
        costs[to] = costs[v] + cost
        heappush(q, P(costs[to], to))        
        
  return costs

min_costs_in_yen = min_costs(Yen, s)
min_costs_in_snuuk = min_costs(Snuuk, t)

total_costs = [
  min_costs_in_yen[i] + min_costs_in_snuuk[i] 
  for i in range(n)
]

# 両替所が閉鎖されていく
for i in range(n - 1, 0, -1):
  total_costs[i - 1] = min(total_costs[i - 1], total_costs[i])
                      
    
for i in range(n):
  print((10 ** 15 - total_costs[i]))
# Original solution
#!/usr/bin/env python3
#SoundHound D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,s,t = LI()
cost1 = [[inf]*n for _ in range(n)]
cost2 = [[inf]*n for _ in range(n)]
for _ in range(m):
    u,v,a,b = LI()
    cost1[u-1][v-1] = a
    cost1[v-1][u-1] = a
    cost2[u-1][v-1] = b
    cost2[v-1][u-1] = b

def dijkstra(s,cost):
    d = [inf]*n
    used = [False]*n
    d[s] = 0

    while 1:
        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

c1 = dijkstra(s-1,cost1)
c2 = dijkstra(t-1,cost2)
c = [c1[i] + c2[i] for i in range(n)]
money = 10**15
for i in range(n):
    ans = money - min(c[i:])
    print(ans)


# Optimized solution
#!/usr/bin/env python3
#SoundHound D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,s,t = LI()
graph1 = [[] for _ in range(n)]
graph2 = [[] for _ in range(n)]
for _ in range(m):
    u,v,a,b = LI()
    graph1[u-1].append((v-1,a))
    graph1[v-1].append((u-1,a))
    graph2[u-1].append((v-1,b))
    graph2[v-1].append((u-1,b))

def dijkstra(s,graph):
    d = [inf]*n
    d[s] = 0
    h = [(0,s)]
    while h:
        c,v = heappop(h)
        if d[v] < c:
            continue
        for t,cost in graph[v]:
            if d[v] + cost < d[t]:
                d[t] = d[v] + cost
                heappush(h,(d[t],t))
    return d

c1 = dijkstra(s-1,graph1)
c2 = dijkstra(t-1,graph2)
c = [c1[i] + c2[i] for i in range(n)]
money = 10**15
for i in range(n):
    ans = money - min(c[i:])
    print(ans)
# Original solution
#!/usr/bin/env python3
#SoundHound D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,s,t = LI()
graph1 = [[] for _ in range(n)]
graph2 = [[] for _ in range(n)]
for _ in range(m):
    u,v,a,b = LI()
    graph1[u-1].append((v-1,a))
    graph1[v-1].append((u-1,a))
    graph2[u-1].append((v-1,b))
    graph2[v-1].append((u-1,b))

def dijkstra(s,graph):
    d = [inf]*n
    d[s] = 0
    h = [(0,s)]
    while h:
        c,v = heappop(h)
        if d[v] < c:
            continue
        for t,cost in graph[v]:
            if d[v] + cost < d[t]:
                d[t] = d[v] + cost
                heappush(h,(d[t],t))
    return d

c1 = dijkstra(s-1,graph1)
c2 = dijkstra(t-1,graph2)
c = [c1[i] + c2[i] for i in range(n)]
money = 10**15
for i in range(n):
    ans = money - min(c[i:])
    print(ans)


# Optimized solution
#!/usr/bin/env python3
#SoundHound D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,s,t = LI()
graph1 = [[] for _ in range(n)]
graph2 = [[] for _ in range(n)]
for _ in range(m):
    u,v,a,b = LI()
    graph1[u-1].append((v-1,a))
    graph1[v-1].append((u-1,a))
    graph2[u-1].append((v-1,b))
    graph2[v-1].append((u-1,b))

def dijkstra(s,graph):
    d = [inf]*n
    d[s] = 0
    h = [(0,s)]
    while h:
        c,v = heappop(h)
        if d[v] < c:
            continue
        for t,cost in graph[v]:
            if d[v] + cost < d[t]:
                d[t] = d[v] + cost
                heappush(h,(d[t],t))
    return d

c1 = dijkstra(s-1,graph1)
c2 = dijkstra(t-1,graph2)
c = [c1[i] + c2[i] for i in range(n)]
money = 10**15
mi = c[-1]
for i in range(n-1)[::-1]:
    mi = min(mi,c[i])
    c[i] = mi
for i in range(n):
    print((money - c[i]))
# Original solution
n, m, s, t = list(map(int, input().split()))

root1 = []
for i in range(n):
    root1_ = [0] * n
    root1.append(root1_)
root2 = []
for i in range(n):
    root2_ = [0] * n
    root2.append(root2_)
    
for i in range(m):
    root = list(map(int, input().split()))
    root1[root[0] - 1][root[1] - 1] = root[2]
    root1[root[1] - 1][root[0] - 1] = root[2]
    root2[root[0] - 1][root[1] - 1] = root[3]
    root2[root[1] - 1][root[0] - 1] = root[3]

def min_cost(start, end, root):
    confirmed = [[start, 0]]
    edge = [start]
    while len(confirmed) < n:
        candidate = []
        for i in range(len(edge)):
            for j in range(n):
                if root[edge[i] - 1][j] != 0:
                    for k in range(len(confirmed)):
                        if confirmed[k][0] == edge[i]:
                            candidate.append([j + 1, confirmed[k][1] + root[edge[i] - 1][j]])
                            break
        candidate.sort(key = lambda x: x[1])
        for i in range(len(candidate)):
            if candidate[i][0] in [confirmed[i][0] for i in range(len(confirmed))]:
                continue
            else:
                confirmed.append(candidate[i])
                break
        for i in range(len(confirmed)):
            edge.append(confirmed[i][0])
        exclude = []
        for i in range(len(edge)):
            flag = True
            for j in range(n):                
                if root[edge[i] - 1][j] != 0 and (j + 1) not in edge:
                    flag = False
                    break
            if flag == True:
                exclude.append(edge[i])
        edge = list(set(edge) - set(exclude))
    for i in range(len(confirmed)):
        if confirmed[i][0] == end:
            return confirmed[i][1]

cost = []
for i in range(n):
    cost1 = min_cost(s, i + 1, root1)
    cost2 = min_cost(i + 1, t, root2)
    cost.append(cost1 + cost2)
for i in range(n):
    new_cost = cost[i:]
    print((10 ** 15 - min(new_cost)))

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

root1 = {}
root2 = {}
   
for i in range(m):
    u, v, a, b = list(map(int, input().split()))
    root1[(u, v)] = a
    root2[(u, v)] = b

def edge(G, x):
    return([(b, G[(a, b)]) for (a, b) in G if a == x] + [(a, G[(a, b)]) for (a, b) in G if b == x])

def min_cost(G, start, end):
    S = {start: 0}
    D = {}
    while len(S) > 0:
        x = select_min(S)
        m = S[x]
        del S[x]
        D[x] = m
        for (y, w) in edge(G, x):
            if y in S:
                if S[y] > m + w:
                    S[y] = m + w
            elif y not in D:
                S[y] = m + w
    return D[end]

def select_min(S):
    m = -1
    for a in S:
        if m == -1 or m > S[a]:
            x = a
            m = S[a]
    return x

cost = []
for i in range(n):
    cost.append(min_cost(root1, s, i + 1) + min_cost(root2, i + 1, t))

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