import heapq

def dijkstra(start,goal,graph):



    INF = 2 << 20

    node_num = len(graph) 

    visited = [False] * node_num

    costs = [INF] * node_num

    pq = []

    costs[start] = 0

    heapq.heappush(pq, [0,start])

    while not len(pq) == 0:



        cur_cost,cur_node = heapq.heappop(pq)

        if visited[cur_node]:

            continue

        if all(visited[1:]):

            break

        visited[cur_node] = True

        costs[cur_node] = cur_cost

        for i in range(node_num):

            if not visited[i]:

                heapq.heappush(pq,[graph[cur_node][i] + costs[cur_node],i])

    return costs[goal]



n = eval(input())

m = eval(input())

INF = 2 << 20

graph = [[INF] * (n+1) for _ in range(n+1)]

for _ in range(m):

    a,b,c,d = list(map(int,input().split(",")))

    graph[a][b] = c

    graph[b][a] = d

home,shop,reward,price = list(map(int,input().split(",")))

cost = dijkstra(home,shop,graph) + dijkstra(shop,home,graph)

print(reward - price - cost)
import heapq

def dijkstra(start,goal,graph):



    INF = 2 << 20

    node_num = len(graph) 

    visited = [False] * node_num

    costs = [INF] * node_num

    pq = []

    costs[start] = 0

    heapq.heappush(pq, [0,start])

    while not len(pq) == 0:



        cur_cost,cur_node = heapq.heappop(pq)

        if visited[cur_node]:

            continue

        visited[cur_node] = True

        costs[cur_node] = cur_cost

        for i in range(node_num):

            if not visited[i]:

                heapq.heappush(pq,[graph[cur_node][i] + costs[cur_node],i])

    return costs[goal]



n = eval(input())

m = eval(input())

INF = 2 << 20

graph = [[INF] * (n+1) for _ in range(n+1)]

for _ in range(m):

    a,b,c,d = list(map(int,input().split(",")))

    graph[a][b] = c

    graph[b][a] = d

home,shop,reward,price = list(map(int,input().split(",")))

cost = dijkstra(home,shop,graph) + dijkstra(shop,home,graph)

print(reward - price - cost)
import heapq


def dijkstra(start, goal, graph):
    INF = 2 << 20
    node_num = len(graph)
    visited = [False] * node_num
    costs = [INF] * node_num
    pq = []
    costs[start] = 0
    heapq.heappush(pq, [0, start])
    while not len(pq) == 0:
        cur_cost, cur_node = heapq.heappop(pq)
        if visited[cur_node]:
            continue
        if all(visited[1:]):
            break
        visited[cur_node] = True
        costs[cur_node] = cur_cost
        for i in range(node_num):
            if not visited[i]:
                heapq.heappush(pq, [graph[cur_node][i] + costs[cur_node], i])
    return costs[goal]


n = eval(input())
m = eval(input())
INF = 2 << 20
graph = [[INF] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    a, b, c, d = list(map(int, input().split(",")))
    graph[a][b] = c
    graph[b][a] = d
home, shop, reward, price = list(map(int, input().split(",")))
cost = dijkstra(home, shop, graph) + dijkstra(shop, home, graph)
print(reward - price - cost)

import heapq


def dijkstra(start, goal, graph):
    INF = 2 << 20
    node_num = len(graph)
    visited = [False] * node_num
    costs = [INF] * node_num
    pq = []
    costs[start] = 0
    heapq.heappush(pq, [0, start])
    while not len(pq) == 0:
        cur_cost, cur_node = heapq.heappop(pq)
        if visited[cur_node]:
            continue
        visited[cur_node] = True
        costs[cur_node] = cur_cost
        for i in range(node_num):
            if not visited[i]:
                heapq.heappush(pq, [graph[cur_node][i] + costs[cur_node], i])
    return costs[goal]


n = eval(input())
m = eval(input())
INF = 2 << 20
graph = [[INF] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    a, b, c, d = list(map(int, input().split(",")))
    graph[a][b] = c
    graph[b][a] = d
home, shop, reward, price = list(map(int, input().split(",")))
cost = dijkstra(home, shop, graph) + dijkstra(shop, home, graph)
print(reward - price - cost)

-        if all(visited[1:]): -            break