#include <bits/stdc++.h>

//Cost,Pos
typedef std::pair<int, int> P;

struct edge{
	int to, cost;
	edge(int a, int b):to(a), cost(b){};
};

const int max = 25; 
const int inf = 1000000000;

int n, m;
std::vector<edge> g[max];
int d[max];

void dijkstra(int s){
	std::priority_queue<P, std::vector<P>, std::greater<P> > que;
	for(int i = 0; i <= n; i++)d[i] = inf;
	d[s] = 0;
	que.push(P(0, s));

	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first)continue;
		for(int i = 0; i < g[v].size(); i++){
			edge e = g[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
	char ch;
	std::cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b, c, d;
		std::cin >> a >> ch >> b >> ch >> c >> ch >> d;
		edge f(b, c), s(a, d);
		g[a].push_back(f);
		g[b].push_back(s);
	}
	int x1, x2, y1, y2;
	std::cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;
	y1 -= y2;
	dijkstra(x1);
	y1 -= d[x2];
	dijkstra(x2);
	y1 -= d[x1];
	std::cout << y1 << std::endl;

	return 0;
}