#define scanf_s scanf
#include <stdio.h>
#include<iostream>
#include <list>
#include <vector>
#include <iostream>
using namespace std;
#define MAX 101
struct node
{
	list<int> li;
	list<int> cost;
};
int  sum = 0, n, m, s, g, ans,flag = 0,min = -1;
void sai(int N, int a,int f) {
	if (N < m) {
		if (f == a) { //&& flag == 0) {
			if (min == -1 || min > sum) min = sum;
			return;
		}
		else {
			for (auto i = x[a].li.begin(), j = x[a].cost.begin(); i != x[a].li.end(); ++i, ++j) {
				if (min == -1 || min > sum) {
					sum += *j;
					sai(N + 1, *i, f);
					sum -= *j;
				}
			}
		}
	}
}
int main()
{
	int a, b, c, d, V, P;
	scanf_s("%d", &n);
	scanf_s("%d", &m);
	for (int i = 0; i < m; ++i) {
		scanf_s("%d,%d,%d,%d", &a, &b, &c, &d);
		x[a].li.push_back(b); x[a].cost.push_back(c);
		x[b].li.push_back(a); x[b].cost.push_back(d);
	}
	for (int k = 1; k <= n; ++k) {
		for (auto i = x[k].li.begin(), j = x[k].cost.begin(); i != x[k].li.end(); ++i, ++j) {
		}
	}
	scanf_s("%d,%d,%d,%d", &s, &g, &V, &P);
	sai(0, s, g);
	ans += min; min = -1; sum = 0;
	sai(0, g, s);
	ans += min;
	ans = V - (ans + P);
	printf("%d\n", ans);
}