#include <cstdlib>
#include <cstdio>
#include <map>
#define number(node) edge_to[node][0]
#define INFINITY 999999
using namespace std;
int n, m, start[2], paid, pole, cost[2][20], edge_to[20][21], edge_cost[20][21];

int comp_0(const void *a, const void *b)
{
    return cost[0][*(int*)a] - cost[0][*(int*)b];
}

int comp_1(const void *a, const void *b)
{
    return cost[1][*(int*)a] - cost[1][*(int*)b];
}

int main()
{
    int from, to, c1, c2;
    fill((int *)edge_to, (int *)(edge_to + 20), 0);
    fill((int *)edge_cost, (int *)(edge_cost + 20), 0);
    fill((int *)cost, (int *)(cost + 2), INFINITY);
    
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        scanf("%d,%d,%d,%d", &from, &to, &c1, &c2);
        edge_to[from][++number(from)] = to;
        edge_cost[from][number(from)] = c1;
        edge_to[to][++number(to)] = from;
        edge_cost[to][number(to)] = c2;
    }
    
    scanf("%d,%d,%d,%d", &start[0], &start[1], &paid, &pole);
    for (int g = 0; g < 2; g++)
    {
        int unchecked[20], k = 0;
        cost[g][start[g]] = 0;
        for (int i = 1; i <= number(start[g]); i++)
            cost[g][edge_to[start[g]][i]] = edge_cost[start[g]][i];
        for (int i = 1; i <= n; i++)
            if (i != start[g]) unchecked[k++] = i;

        while (k > 0)
        {
            qsort(unchecked, k, sizeof(int), (g ? comp_1 : comp_0));
            for (int i = 1; i <= number(unchecked[0]); i++)
                if (cost[g][edge_to[unchecked[0]][i]] > cost[g][unchecked[0]] + edge_cost[unchecked[0]][i])
                    cost[g][edge_to[unchecked[0]][i]] = cost[g][unchecked[0]] + edge_cost[unchecked[0]][i];
            unchecked[0] = unchecked[--k];
        }
    }
    
    printf("%d,%d,%d,%d\n", paid , pole , cost[0][start[1]] , cost[1][start[0]]);
    return 0;
}