#include <cstdio>
#include <algorithm>

using namespace std;

int search(int n, int m, int passed[], int path[][3], int start, int end) {
    int cost = -1, s, c;
    if (start == end) {
        return 0;
    }
    passed[start - 1] = 1;
    for (int i = 0; i < m * 2; i++) {
        if (path[i][0] == start && passed[path[i][1] - 1] == 0) {
            s = search(n, m, passed, path, path[i][1], end);
            c = path[i][2] + s;
            if (s == -1) continue;
            if (cost == -1) cost = c;
            else cost = min(cost, c);
        }
    }
    passed[start - 1] = 0;
    return cost;
}

int main(void) {
    int n, m;
    scanf("%d", &n);
    scanf("%d", &m);
    int path[m * 2][3];
    for (int i = 0; i < m; i++) {
        int a, b, c, d;
        scanf("%d,%d,%d,%d", &a, &b, &c, &d);
        path[i * 2][0] = a;
        path[i * 2][1] = b;
        path[i * 2][2] = c;
        path[i * 2 + 1][0] = b;
        path[i * 2 + 1][1] = a;
        path[i * 2 + 1][2] = d;
    }
    int start, end, y1, y2;
    scanf("%d,%d,%d,%d", &start, &end, &y1, &y2);
    int passed[n];
    for (int i = 0; i < n; i++) passed[i] = 0;
    int p1 = search(n, m, passed, path, start, end);
    for (int i = 0; i < n; i++) passed[i] = 0;
    int p2 = search(n, m, passed, path, end, start);
    int cost = y1 - y2 - p1 - p2;
    printf("%d\n", cost);
    return 0;
}