//这道题在HDU上好像超时了不知道什么原因

#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1005;
const int INF =1000000000;
int G[N][N],C[N][N];
int d[N],c[N];
bool vis[N];
int n,m;
void Dijkstra(int s){
    fill(d,d+N,INF);
    fill(c,c+N,INF);
    d[s] = 0;
    c[s] = 0;
    for(int i = 0; i <= n; i++){
        int u = -1,MIN = INF;
        for(int j = 0; j <= n; j++){
            if(vis[j] == false&& d[j] < MIN){
                u = j;
                MIN = d[j];
            }
        }
        if(u == -1) return; 
        vis[u] = true;
        for(int v = 0; v <= n; v++){
            if(vis[v] == false && G[u][v] != INF){
                if(d[u] + G[u][v] < d[v]){
                    d[v] = d[u] + G[u][v];
                    c[v] = c[u] + C[u][v];
                }else if(d[u] + G[u][v] == d[v]&&c[u] + C[u][v] < c[v]){
                    c[v] = c[u] + C[u][v];
                }
            }
        } 
    }

}
int main(){
    int a,b,w,p,st,ed;
    while(cin>>n>>m){
        if(n==0&&m==0) break;
        fill(G[0],G[0]+N*N,INF);
        fill(C[0],C[0]+N*N,INF);
        for(int i=0;i<N;i++){
            vis[i] = false;
        }
        for(int i = 0; i < m; i++){
            cin>>a>>b>>w>>p;
            if(w < G[a][b])
            {
                G[a][b] = G[b][a] = w;
                C[a][b] = C[b][a] = p;
            }
            else if(w == G[a][b] && p < C[a][b]){
                    C[a][b] = C[b][a] = p;
                 }

        }
        cin>>st>>ed;
        Dijkstra(st);
        cout<<d[ed]<<" "<<c[ed]<<endl;
    }

    return 0;
}