#include <iostream>
#include <stdlib.h>
#define inf 99999

using namespace std;

bool check(int *a, int n)
{
	for(int i = 1; i <= n; i++){
		if(a[i] == 0){
			return true;
		}
	}
	
	return false;
}

int dij(int **a, int n, int s, int t)
{
	int *label, current=s, next, *cost;
	
	label = (int *)calloc(n+1, sizeof(int));
	cost = (int *)calloc(n+1, sizeof(int));
	label[current] = 1;
	
	for(int i = 1; i <= n; i++){
		cost[i] = a[current][i];
	}
	
	while(check(label, n)){
		for(int i = 1, min = inf; i <= n; i++){
			if(min > cost[i] && label[i] == 0){
				min = cost[i];
				next = i;
			}
		}
		label[next] = 1;
		for(int i = 1; i <= n; i++){
			if(label[i] == 0 && cost[i] > (a[next][i]+cost[next])){
				cost[i] = a[next][i] + cost[next];
			}
		}
		current = next;
	}
	next = cost[t];
	
	free(cost);
	free(label);
	
	return next;
}

int main(int argc, char **argv)
{
	int n, m, **ary1, **ary2, a, b, c, d;
	
	cin >> n;
	cin >> m;
	
	ary1 = (int **)calloc(n+1, sizeof(int));
	ary2 = (int **)calloc(n+1, sizeof(int));
	for(int i = 1; i <= n; i++){
		ary1[i] = (int *)calloc(n+1, sizeof(int));
		ary2[i] = (int *)calloc(n+1, sizeof(int));
	}
	
	for(int i = 0; i < m; i++){
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		ary1[a][b] = ary1[b][a] = c;
		ary2[b][a] = ary2[a][b] = d;
	}
	scanf("%d,%d,%d,%d", &a, &b, &c, &d);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i != j && ary1[i][j] == 0){
				ary1[i][j] = inf;
				ary2[i][j] = inf;
			}
		}
	}
	
	c -= dij(ary1, n, a, b);
	c -= d;
	c -= dij(ary2, n, b, a);
	cout << c << endl;
	
	for(int i = 1; i <= n; i++){
		free(ary1[i]);
		free(ary2[i]);
	}
	free(ary1);
	free(ary2);
	
	return 0;
}