#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>

int n, m, start, goal, money, pole;
int roads[21][21];
int in[4];
std::string input;

int check( int pos, int hbt, unsigned int c ){
	if( pos == goal ) return c;

	unsigned int cost = -1;

	for( int i = 1; i <= m; ++i ){
		if( roads[pos][i] != -1 && !(hbt & 1 << i) ){
			cost = std::min( cost, (unsigned int)check( i, hbt|1<<i, c + roads[pos][i] ) );
		}
	}

	return cost;
}

int main(){
	memset( roads, -1, sizeof( roads ) );

	std::cin >> n >> m;

	for( int i = 0; i < m; ++i ){
		std::cin >> input;

		sscanf( input.c_str(), "%d,%d,%d,%d", in, &in[1], &in[2], &in[3] );

		roads[ in[0] ][ in[1] ] = in[2];
		roads[ in[1] ][ in[0] ] = in[3];
	}

	std::cin >> input;
	sscanf( input.c_str(), "%d,%d,%d,%d", &start, &goal, &money, &pole );

	money -= pole;

	int cost = check( start, 0, 0 );
	std::swap( start, goal );
	cost += check( start, 0, 0 );

	std::cout << money - cost << std::endl;
}