#include<bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n, m;
    cin >> n >> m;
    int dis[25][25];
    rep(i, 25){
        rep(j, 25){
            dis[i][j] = IINF;
        }
        dis[i][i] = 0;
    }
    string tmp;
    int l = 0;
    rep(i, m){
        cin >> tmp;
        l = 0;
        int a = 0, b = 0, c = 0, d = 0;
        while(true){
            if(tmp[l] == ','){
                break;
            }
            a *= 10;
            a += tmp[l] - '0';
            l++;
        }
        l++;
        while(true){
            if(tmp[l] == ','){
                break;
            }
            b *= 10;
            b += tmp[l] - '0';
            l++;
        }
        l++;
        while(true){
            if(tmp[l] == ','){
                break;
            }
            c *= 10;
            c += tmp[l] - '0';
            l++;
        }
        l++;
        while(l < tmp.size()){
            d *= 10;
            d += tmp[l] - '0';
            l++;
        }
        a--;
        b--;
        dis[a][b] = c;
        dis[b][a] = d;
    }
    cin >> tmp;
    l = 0;
    int s = 0, g = 0, v = 0, p = 0;
    while(true){
        if(tmp[l] == ','){
            break;
        }
        s *= 10;
        s += tmp[l] - '0';
        l++;
    }
    l++;
    while(true){
        if(tmp[l] == ','){
            break;
        }
        g *= 10;
        g += tmp[l] - '0';
        l++;
    }
    l++;
    while(true){
        if(tmp[l] == ','){
            break;
        }
        v *= 10;
        v += tmp[l] - '0';
        l++;
    }
    l++;
    while(l < tmp.size()){
        p *= 10;
        p += tmp[l] - '0';
        l++;
    }
    s--;
    g--;
    rep(k, n){
        rep(i, n){
            rep(j, n){
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
    int ans = v - (dis[s][g] + dis[g][s] + p);
    cout << ans << endl;
    return 0;
}
