INF = 1000000





def bellman_ford(graph, source):

    lg = len(graph)

    unused = list(range(lg))

    d = [INF] * (lg)

    d[source] = 0



    while unused:

        v = min(unused, key=lambda u: d[u])

        unused.remove(v)

        for u in range(n + 1):

            d[u] = min(d[u], d[v] + graph[v][u])



    return d



n = int(eval(input()))

m = int(eval(input()))



cost = [[INF] * (n + 1) for i in range(n + 1)]

for i in range(m):

    ai, bi, ci, di = list(map(int, input().split(',')))

    cost[ai][bi] = ci

    cost[bi][ai] = di



x1, x2, y1, y2 = list(map(int, input().split(',')))



d_go = bellman_ford(cost, x1)[x2]

d_back = bellman_ford(cost, x2)[x1]



print((y1 - y2 - d_go - d_back))
INF = 1e12





def dijkstra(graph, source):

    lg = len(graph)

    unused = list(range(lg))

    d = [INF] * (lg)

    d[source] = 0



    while unused:

        v = min(unused, key=lambda u: d[u])

        unused.remove(v)

        for u in range(n + 1):

            d[u] = min(d[u], d[v] + graph[v][u])



    return d



n = int(eval(input()))

m = int(eval(input()))



cost = [[INF] * (n + 1) for i in range(n + 1)]

for i in range(m):

    ai, bi, ci, di = list(map(int, input().split(',')))

    cost[ai][bi] = ci

    cost[bi][ai] = di



x1, x2, y1, y2 = list(map(int, input().split(',')))



d_go = dijkstra(cost, x1)[x2]

d_back = dijkstra(cost, x2)[x1]



print((y1 - y2 - d_go - d_back))
INF = 1000000


def bellman_ford(graph, source):
    lg = len(graph)
    unused = list(range(lg))
    d = [INF] * (lg)
    d[source] = 0
    while unused:
        v = min(unused, key=lambda u: d[u])
        unused.remove(v)
        for u in range(n + 1):
            d[u] = min(d[u], d[v] + graph[v][u])
    return d


n = int(eval(input()))
m = int(eval(input()))
cost = [[INF] * (n + 1) for i in range(n + 1)]
for i in range(m):
    ai, bi, ci, di = list(map(int, input().split(",")))
    cost[ai][bi] = ci
    cost[bi][ai] = di
x1, x2, y1, y2 = list(map(int, input().split(",")))
d_go = bellman_ford(cost, x1)[x2]
d_back = bellman_ford(cost, x2)[x1]
print((y1 - y2 - d_go - d_back))

INF = 1e12


def dijkstra(graph, source):
    lg = len(graph)
    unused = list(range(lg))
    d = [INF] * (lg)
    d[source] = 0
    while unused:
        v = min(unused, key=lambda u: d[u])
        unused.remove(v)
        for u in range(n + 1):
            d[u] = min(d[u], d[v] + graph[v][u])
    return d


n = int(eval(input()))
m = int(eval(input()))
cost = [[INF] * (n + 1) for i in range(n + 1)]
for i in range(m):
    ai, bi, ci, di = list(map(int, input().split(",")))
    cost[ai][bi] = ci
    cost[bi][ai] = di
x1, x2, y1, y2 = list(map(int, input().split(",")))
d_go = dijkstra(cost, x1)[x2]
d_back = dijkstra(cost, x2)[x1]
print((y1 - y2 - d_go - d_back))

-INF = 1000000 +INF = 1e12 -def bellman_ford(graph, source): +def dijkstra(graph, source): -d_go = bellman_ford(cost, x1)[x2] -d_back = bellman_ford(cost, x2)[x1] +d_go = dijkstra(cost, x1)[x2] +d_back = dijkstra(cost, x2)[x1]