#include <iostream>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

#define INF 1<<20
#define MAX_V 20

bool done[MAX_V];
int d[MAX_V];
int V;
int cost[MAX_V+1][MAX_V+1];

int dijkstra(int s, int t) {
  fill(done, done+V, false);
  fill(d, d+V, INF);
  
  d[s] = 0;

  while(1) {
    int v = -1;
    for(int u = 0; u < V; u++) {
      // find minimum
      if(!done[u] && ( v == -1 || d[u]<d[v] )) {
	v = u;
      }
    }
    if(v == -1) break;

    done[v] = true;

    // relax
    for(int u = 0; u < V; u++) {
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
  
  return d[t];
}

/*
struct edge{ int to, cost; };

typedef pair<int, int> Pii; // cost, vertex

int V;
int d[MAX_V];

vector<edge> G[MAX_V];

void dijkstra(int s) {
  priority_queue<Pii> Q;
  fill(d, d+V, INF);
  d[s] = 0;
  Q.push(Pii(0, s));

  while(!Q.empty()) {
    Pii p = Q.top(); Q.pop();
    int v = p.second;
    
    if(d[v] < p.first) continue;
    
    for(int i=0; i<G[v].size(); i++) {
      edge e = G[v][i];
      
      if(d[i] > d[v]+e.cost) {
	d[i] = d[v]+e.cost;
	Q.push(Pii(d[i], e.to));
      }
    }
  }
}

*/

int main() {
  
  int m;
  cin >> V >> m;
  char dd;

  fill(cost[0], cost[MAX_V], INF);
  
  for(int i=0; i<m; i++) {
    int a, b, c, d;
    cin >> a >> dd >> b >> dd >> c >> dd >> d;
    a--, b--;
    cost[a][b] = c;
    cost[b][a] = d;
  }
  
  int x1, x2, y1, y2;
  cin >> x1 >> dd >> x2 >> dd >> y1 >> dd >> y2;
  int ret = y1-y2;

  x1--, x2--;
  ret -= dijkstra(x1, x2);
  ret -= dijkstra(x2, x1);
  
  cout << ret << endl;
  return 0;
}