{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}
{-# OPTIONS_GHC -O2 #-}

import Data.Array.IArray
import Data.Array.Unboxed
import Data.Array.ST
import Data.Char
import Data.List
import Data.Int
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Control.Monad.ST

inf :: Int64
inf = 1000000000000000

getInts :: IO [Int]
getInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

dijkstra :: Array Int [(Int, Int)] -> Int -> [Int64]
dijkstra g source = runST $ do
    ds :: STUArray s Int Int64 <- newArray (1, n) maxBound
    writeArray ds source 0
    let
      step :: S.Set (Int64, Int) -> ST s ()
      step q =
          case S.minView q of
            Nothing -> return ()
            Just ((d, v), q) -> do
              let
                relax q (u, w) = do
                    d <- readArray ds u

                    if d' < d
                      then do
                        writeArray ds u d'
                        return $ S.insert (d', u) q
                      else return q
                  where
                    d' = d + (fromIntegral w)

              foldM relax q (g!v) >>= step

    step $ S.singleton (0, source)

    ds' :: UArray Int Int64 <- freeze ds
    return (elems ds')
  where
    n = snd $ bounds g

main :: IO ()
main = do
	[n, m, s, t] <- getInts
	es <- replicateM m getInts
	let gy = accumArray (flip (:)) [] (1, n) $ concatMap (\[u, v, y, s] -> [(u, (v, y)), (v, (u, y))]) es
	let gs = accumArray (flip (:)) [] (1, n) $ concatMap (\[u, v, y, s] -> [(u, (v, s)), (v, (u, s))]) es
	putStrLn $ unwords $ map show $ map (inf-) $ scanr1 min $ zipWith (+) (dijkstra gy s) (dijkstra gs t) 