#include<iostream>
#include<cstdio>
using namespace std;
int N, M, A, B, C, D, x1, x2, y1, y2;
int w[25][25];

int main(){
	scanf("%d %d", &N, &M);
	for (int i = 0; i < 25; i++){
		for (int  j = 0; j<25; j++){
			w[i][j] = 10000;
		} 
	}
	for (int i = 0; i < M; i++){
		scanf("%d,%d,%d,&d", &A, &B, &C, &D);
		w[A][B] = C;
		w[B][A] = D;
	}
	for (int h = 0; h < N; h++){
		for (int i = 0; i < N; i++){
			for (int j = 0; j < N; j++){
				if (w[i][j]>w[i][h] + w[h][j])w[i][j] = w[i][h] + w[h][j];
			}
		}
	}
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	cout << w[x1][x2] - y1 - y2 << endl;
}