#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
 int i,j,k,m,n,a1,b1,x1,x2,y1,y2,c1,d1,d[21][21];
 cin >> n;
 for (i=1;i<=n;i++) for (j=1;j<n;j++) if (i==j) d[i][j]=0; else d[i][j]=1000000000;
 cin >> m;
 for (i=0;i<m;i++) {
	 scanf("%d,%d,%d,%d",&a1,&b1,&c1,&d1);
     d[a1][b1]=c1; d[b1][a1]=d1;
 }
 scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
 for (k=1;k<=n;k++) for (i=1;i<=n;i++) for (j=1;j<=n;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
 cout << y1-y2-d[x1][x2]-d[x2][x1] << endl;
 return 0;	
}