from heapq import*

def dijkstra(s,e):

  g=10**6

  d=[10**18]*n

  f=[1]*n

  d[s]=f[s]=0

  q=[]

  for a,b in e[s]:heappush(q,a*g+b)

  while q:

    m=heappop(q)

    if f[m%g]<1:continue

    v=m%g

    x=d[v]=m//g

    f[v]=0

    for y,w in e[v]:

      if f[w]:heappush(q,(x+y)*g+w)

  return d

(n,m,s,t),*z=[list(map(int,t.split()))for t in open(0)]

e,f=eval('[[]for _ in"_"*n],'*2)

for u,v,a,b in z:

  u-=1

  v-=1

  e[u]+=(a,v),

  e[v]+=(a,u),

  f[u]+=(b,v),

  f[v]+=(b,u),

a=[]

m=0

for y,s in zip(dijkstra(s-1,e)[::-1],dijkstra(t-1,f)[::-1]):

  m=max(m,10**15-y-s)

  a+=m,

print((*a[::-1]))
from heapq import*

def dijkstra(s,e):

 g=10**6;d=[10**18]*n;f=[1]*n;d[s]=f[s]=0;q=[]

 for a,b in e[s]:heappush(q,a*g+b)

 while q:

  m=heappop(q)

  if f[m%g]:

   v=m%g;x=d[v]=m//g;f[v]=0

   for y,w in e[v]:

    if f[w]:heappush(q,(x+y)*g+w)

 return d

(n,m,s,t),*z=[list(map(int,t.split()))for t in open(0)]

e,f=eval('[[]for _ in"_"*n],'*2)

for u,v,a,b in z:u-=1;v-=1;e[u]+=(a,v),;e[v]+=(a,u),;f[u]+=(b,v),;f[v]+=(b,u),

a,m=[],0

for y,s in zip(dijkstra(s-1,e)[::-1],dijkstra(t-1,f)[::-1]):m=max(m,10**15-y-s);a+=m,

print((*a[::-1]))
from heapq import *


def dijkstra(s, e):
    g = 10**6
    d = [10**18] * n
    f = [1] * n
    d[s] = f[s] = 0
    q = []
    for a, b in e[s]:
        heappush(q, a * g + b)
    while q:
        m = heappop(q)
        if f[m % g] < 1:
            continue
        v = m % g
        x = d[v] = m // g
        f[v] = 0
        for y, w in e[v]:
            if f[w]:
                heappush(q, (x + y) * g + w)
    return d


(n, m, s, t), *z = [list(map(int, t.split())) for t in open(0)]
e, f = eval('[[]for _ in"_"*n],' * 2)
for u, v, a, b in z:
    u -= 1
    v -= 1
    e[u] += ((a, v),)
    e[v] += ((a, u),)
    f[u] += ((b, v),)
    f[v] += ((b, u),)
a = []
m = 0
for y, s in zip(dijkstra(s - 1, e)[::-1], dijkstra(t - 1, f)[::-1]):
    m = max(m, 10**15 - y - s)
    a += (m,)
print((*a[::-1]))

from heapq import *


def dijkstra(s, e):
    g = 10**6
    d = [10**18] * n
    f = [1] * n
    d[s] = f[s] = 0
    q = []
    for a, b in e[s]:
        heappush(q, a * g + b)
    while q:
        m = heappop(q)
        if f[m % g]:
            v = m % g
            x = d[v] = m // g
            f[v] = 0
            for y, w in e[v]:
                if f[w]:
                    heappush(q, (x + y) * g + w)
    return d


(n, m, s, t), *z = [list(map(int, t.split())) for t in open(0)]
e, f = eval('[[]for _ in"_"*n],' * 2)
for u, v, a, b in z:
    u -= 1
    v -= 1
    e[u] += ((a, v),)
    e[v] += ((a, u),)
    f[u] += ((b, v),)
    f[v] += ((b, u),)
a, m = [], 0
for y, s in zip(dijkstra(s - 1, e)[::-1], dijkstra(t - 1, f)[::-1]):
    m = max(m, 10**15 - y - s)
    a += (m,)
print((*a[::-1]))

-        if f[m % g] < 1: -            continue -        v = m % g -        x = d[v] = m // g -        f[v] = 0 -        for y, w in e[v]: -            if f[w]: -                heappush(q, (x + y) * g + w) +        if f[m % g]: +            v = m % g +            x = d[v] = m // g +            f[v] = 0 +            for y, w in e[v]: +                if f[w]: +                    heappush(q, (x + y) * g + w) -a = [] -m = 0 +a, m = [], 0