#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define MAX 20

class Node {
public:
	vector<int> to, ct;
};

Node node[MAX];

class Trl {
public:
	int p, cost;
	Trl(int p, int c) : p(p), cost(c) {}
	bool operator<(const Trl& n) const {
		return cost > n.cost;
	}
};

int N;

int dijkstra(int s, int d) {
	priority_queue<Trl> q;
	bool v[MAX] = {0};
	q.push(Trl(s, 0));
	while (!q.empty()) {
		Trl t=q.top(); q.pop();
		if (v[t.p]) continue;
		v[t.p] = true;
		if (t.p == d) return t.cost;
		for (int i=0; i<node[t.p].to.size(); i++) {
			int next = node[t.p].to[i];
			if (v[next]) continue;
			q.push(Trl(next, t.cost+node[t.p].ct[i]));
		}
	}
	return -1;
}

int main() {
	while (cin >> N, N) {
		for (int i=0; i<MAX ;i++) {
			node[i].to.clear();
			node[i].ct.clear();
		}
		int n;
		char c;
		int w,x,y,z;
		cin >> n;
		while (n--) {
			cin >> w >> c >> x >> c >> y >> c >> z;
			node[w].to.push_back(x);
			node[x].to.push_back(w);
			node[w].ct.push_back(y);
			node[x].ct.push_back(z);
		}
		cin >> w >> c >> x >> c >> y >> c >> z;
		cout << y-z-dijkstra(w,x)-dijkstra(x,w) << endl;
	}
	return 0;
}