import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;

void main() {
	int n = to!int(readln().strip());
	int m = to!int(readln().strip());
	int[20][20] g;
	foreach(i; 0..20) {
		foreach(j; 0..20) {
			g[i][j] = int.max/100;
		}
	}
	foreach(i; 0..m) {
		auto s = map!(a => to!int(a))(readln().strip().split(","));
		int a = s[0]-1;
		int b = s[1]-1;
		int c = s[2];
		int d = s[3];
		g[a][b] = c;
		g[b][a] = d;
	}
	auto s = map!(a => to!int(a))(readln().strip().split(","));
	int x1 = s[0]-1;
	int x2 = s[1]-1;
	int y1 = s[2];
	int y2 = s[3];
	foreach(k; 0..n) {
		foreach(i; 0..n) {
			foreach(j; 0..n) {
				g[i][j] = min(g[i][j], g[i][k]+g[k][j]);
			}
		}
	}
	writeln(y1-y2-g[x1][x2]-g[x2][x1]);
}