#include<bits/stdc++.h>
#include<vector>
using namespace std;
const int maxn=505;
const int INF = 1e9+5;
int N,M,S,D,c1,c2,dist,cost;
int weights[maxn];
int G[maxn][maxn];
int C[maxn][maxn];
int d[maxn];
bool vis[maxn]={false};
vector<int> pre[maxn];
void Dijkstra(int s){
fill(d,d+N,INF);
d[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){
Min = d[j];
u = j;
}
}
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];
pre[v].clear();
pre[v].push_back(u);
}else if(d[u] + G[u][v] == d[v]){
pre[v].push_back(u);
}
}
}
}
}
int totalcost=INF;
vector<int> path,tempPath;
void DFS(int v){
if(v==S){
tempPath.push_back(v);
int value=0;
for(int i=tempPath.size()-1;i >0; i--){
int x=tempPath[i];
int y=tempPath[i-1];
value += C[x][y];
}
if(value < totalcost) {
totalcost = value;
path.clear();
for(int i=tempPath.size()-1;i >=0; i--){
path.push_back(tempPath[i]);
}
}
tempPath.pop_back();
return;
}
tempPath.push_back(v);
for(int i=0;i<pre[v].size();i++){
DFS(pre[v][i]);
}
tempPath.pop_back();
}
int main(){
fill(G[0],G[0]+maxn*maxn,INF);
scanf("%d%d%d%d",&N,&M,&S,&D);
for(int i=0;i<M;i++){
scanf("%d%d%d%d",&c1,&c2,&dist,&cost);
G[c1][c2]=dist;
C[c1][c2]=cost;
G[c2][c1]=dist;
C[c2][c1]=cost;
}
Dijkstra(S);
DFS(D);
for(int i=0;i<path.size();i++){
printf(i==0?"%d":" %d",path[i]);
}
printf(" %d %d\n",d[D],totalcost);
return 0;
}