Buggy python submission (verdict: Time Limit Exceeded):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

import heapq


class PriorityQueue:
    class Reverse:
        def __init__(self, val):
            self.val = val

        def __lt__(self, other):
            return self.val > other.val

        def __repr__(self):
            return repr(self.val)

    def __init__(self, x=None, desc=False):
        if not x:
            x = []
        if desc:
            for i in range(len(x)):
                x[i] = self.Reverse(x[i])
        self._desc = desc
        self._container = x
        heapq.heapify(self._container)

    @property
    def is_empty(self):
        return not self._container

    def pop(self):
        if self._desc:
            return heapq.heappop(self._container).val
        else:
            return heapq.heappop(self._container)

    def push(self, item):
        if self._desc:
            heapq.heappush(self._container, self.Reverse(item))
        else:
            heapq.heappush(self._container, item)

    def top(self):
        if self._desc:
            return self._container[0].val
        else:
            return self._container[0]

    def sum(self):
        return sum(self._container)

    def __len__(self):
        return len(self._container)


def main():
    from collections import defaultdict
    n, m, s, t = map(int, readline().split())

    edge = defaultdict(list)

    for _ in range(m):
        u, v, a, b = map(int, readline().split())
        edge[u].append((v, a, b))
        edge[v].append((u, a, b))

    dist_s = defaultdict(lambda: float("INF"))
    dist_t = defaultdict(lambda: float("INF"))

    dist_s[s] = 0
    dist_t[t] = 0

    pq = PriorityQueue()
    pq.push((s, 0))

    while pq:
        cur, cost = pq.pop()
        for nx, a, _ in edge[cur]:
            nc = cost + a
            if nc < dist_s[nx]:
                dist_s[nx] = nc
                pq.push((nx, nc))

    pq.push((t, 0))
    while pq:
        cur, cost = pq.pop()
        for nx, _, b in edge[cur]:
            nc = cost + b
            if nc < dist_t[nx]:
                dist_t[nx] = nc
                pq.push((nx, nc))

    res = [0] * (n + 1)
    for i in range(n - 1, -1, -1):
        res[i] = max(res[i + 1], 10 ** 15 - (dist_s[i+1] + dist_t[i+1]))

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


if __name__ == '__main__':
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 5)


def main():
    import heapq
    from collections import defaultdict
    INF = float('INF')

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

    edge = defaultdict(list)

    for _ in range(m):
        u, v, a, b = map(int, readline().split())
        edge[u].append((v, a, b))
        edge[v].append((u, a, b))

    dist_s = defaultdict(lambda: float("INF"))
    dist_t = defaultdict(lambda: float("INF"))

    dist_s[s] = 0
    dist_t[t] = 0

    hq = []
    heapq.heappush(hq, (0, s))

    while hq:
        cost, cur = heapq.heappop(hq)
        for nx, a, _ in edge[cur]:
            nc = cost + a
            if nc < dist_s[nx]:
                dist_s[nx] = nc
                heapq.heappush(hq, (nc, nx))

    heapq.heappush(hq, (0, t))

    while hq:
        cost, cur = heapq.heappop(hq)
        for nx, _, b in edge[cur]:
            nc = cost + b
            if nc < dist_t[nx]:
                dist_t[nx] = nc
                heapq.heappush(hq, (nc, nx))

    res = [0] * (n + 1)
    for i in range(n - 1, -1, -1):
        res[i] = max(res[i + 1], 10 ** 15 - (dist_s[i + 1] + dist_t[i + 1]))

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


if __name__ == '__main__':
    main()