#include <stdio.h>

#define MAX 1000000000
#define min(x, y) ((x) < (y) ? (x) : (y))

int route[21][21];
int cost[21];
int check[21];
int n, m;

void dijkstra(int start) {                                                      
    int i, u;                                                                   
                                                                                
    for (i = 1; i < n + 1; i++) {                                               
        cost[i] = MAX;                                                          
        check[i] = 0;                                                           
    }                                                                           
    cost[start] =0;                                                             
    while (1) {                                                                 
        int v = -1;                                                             
        for (u = 1; u < n + 1; u++) {                                           
            if (check[u] == 0 && (v == -1 || cost[u] < cost[v]))                
                v = u;                                                          
        }                                                                       
        if (v == -1)                                                            
            break;                                                              
        check[v] = 1;                                                           
                                                                                
        for (u = 1; u < n + 1; u++) {                                           
            cost[u] = min(cost[u], cost[v] + route[v][u]);                      
        }                                                                       
    }                                                                           
}

void warshall_floyd() {                                                         
    int i, j, k;                                                                
    for (k = 1; k < n + 1; k++)                                                 
        for (i = 1; i < n + 1; i++)                                             
            for (j = 1; j < n + 1; j++)                                         
                route[i][j] = min(route[i][j], route[i][k] + route[k][j]);      
}

int main(void) {                                                                
    int i, a, b, c, d;                                                          
    int x1, x2, y1, y2;                                                         
    int money;                                                                  
                                                                                
    for (i = 0; i < 21*21; i++) {                                               
        route[i/20][i%20] = MAX;                                                
    }                                                                           
                                                                                
    scanf("%d%d", &n, &m);                                                      
    while (m > 0) {                                                             
        scanf("%d,%d,%d,%d", &a, &b, &c, &d);                                   
        route[a][b] = c;                                                        
        route[b][a] = d;                                                        
        m--;                                                                    
    }                                                                           
    scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);                                   
                                                                                
    dijkstra(x1);                                                               
    money = y1 - y2 - cost[x2];                                                 
    dijkstra(x2);                                                               
    money -= cost[x1];                                                          
    //    warshall_floyd();                                                     
    //money = y1 - (route[x1][x2] + route[x2][x1] + y2);                        
    printf("%d\n", money);                                                      
                                                                                
    return 0;       
}

Measured memory_bytes: 600