{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VMM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S
import System.IO.Unsafe
import Debug.Trace

uread v i = unsafePerformIO $ VM.read v i
uwrite v i a = unsafePerformIO $ VM.write v i a >> return v
umodify v f i = unsafePerformIO $ VM.modify v f i >> return v
uthaw = unsafePerformIO . VU.thaw
ufreeze = unsafePerformIO . VU.freeze

umodifyV v f i = unsafePerformIO $ VMM.modify v f i >> return v
uthawV = unsafePerformIO . V.thaw
ufreezeV = unsafePerformIO . V.freeze

dijkstra
  :: Int  -- ^ nodes
  -> V.Vector [(Int, Int)]  -- ^ edges from i-th node: (end, cost)
  -> Int  -- ^ start node
  -> Int  -- ^ end node
  -> VU.Vector Int  -- ^ constructed graph
dijkstra n edges s t = ufreeze $ snd $ fix (\f (nodes,costs) -> case S.minView nodes of
    Nothing -> (S.empty,costs)
    Just ((c,n), nodes) ->
      if c <= uread costs n
        then
          let es = edges V.! n in
            f $ foldl' (\(ns,cs) (e,ec) ->
              let c' = c + ec in if c' < uread costs e
                then (S.insert (c',e) ns, uwrite cs e c')
                else (ns,cs)
              ) (nodes,costs) es
        else f (nodes,costs)) (nodes0,costs0)
  where
    costs0 :: VM.IOVector Int
    costs0 = uwrite (uthaw $ VU.replicate n maxBound) s 0

    nodes0 :: S.Set (Int,Int)
    nodes0 = S.singleton (0,s)

solve :: Int -> Int -> Int -> Int -> VU.Vector (Int,Int,Int,Int) -> [Int]
solve n m s t trains = map (10^15 -) $ fst $ foldl' (\(acc,prev) i -> let cur = calcCost i `min` prev in (cur:acc,cur)) ([],10^15 :: Int) [n-1,n-2..0]
  where
    yenGraph = dijkstra n (ufreezeV $ VU.foldl' (\gr (u,v,a,b) -> umodifyV (umodifyV gr ((v,a) :) u) ((u,a) :) v) (uthawV $ V.replicate n []) trains) s t
    snookGraph = dijkstra n (ufreezeV $ VU.foldl' (\gr (u,v,a,b) -> umodifyV (umodifyV gr ((v,b) :) u) ((u,b) :) v) (uthawV $ V.replicate n []) trains) t s

    calcCost i = yenGraph VU.! i + snookGraph VU.! i

main = do
  let readInt = fmap (second B.tail) . B.readInt

  (n,m,s,t) <- (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2 - 1, vec VU.! 3 - 1)) . VU.unfoldrN 4 readInt <$> B.getLine
  uvab <- VU.replicateM m $ (\vec -> (vec VU.! 0 - 1, vec VU.! 1 - 1, vec VU.! 2, vec VU.! 3)) . VU.unfoldrN 4 readInt <$> B.getLine
  mapM_ print $ solve n m s t uvab
