import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
class Main {
static InputStreamReader isr = new InputStreamReader(System.in);
static BufferedReader in = new BufferedReader(isr);
static OutputStreamWriter osw = new OutputStreamWriter(System.out);
static BufferedWriter out = new BufferedWriter(osw);
static int N = 1660, INF = 0x3f3fffff;
static int n, m, s, d, a, b, w, c;
//稀疏图,邻接表存储
static int idx;
static int[] h = new int[N];
static int[] e = new int[N];
static int[] ne = new int[N];
//此路长度
static int[] we = new int[N];
//此路费用
static int[] ce = new int[N];
//最短路
static int[] dist = new int[N];
//路径
static int[] path = new int[N];
//花费
static int[] cost = new int[N];
//标记是否已纳入最短路径
static boolean[] flag = new boolean[N];
static {
Arrays.fill(h, -1);
Arrays.fill(path, -1);
Arrays.fill(dist, INF);
}
static void insert(int a, int b, int w, int c) {
e[idx] = b;
ne[idx] = h[a];
we[idx] = w;
ce[idx] = c;
h[a] = idx++;
}
static void dijkstra() {
dist[s] = 0;
for (int i = 0; i < n; i++) {
int min = INF; int pivot = -1;
for (int j = 0; j < n; j++) {
if (!flag[j] && dist[j] < min) {
min = dist[j];
pivot = j;
}
}
flag[pivot] = true;
for (int j = h[pivot]; j != -1 ; j = ne[j]) {
int nx = e[j];
if (!flag[nx] && dist[nx] > dist[pivot] + we[j]) {
dist[nx] = dist[pivot] + we[j];
path[nx] = pivot;
cost[nx] = cost[pivot] + ce[j];
}
else if (dist[nx] == dist[pivot] + we[j]) {
if (cost[nx] > cost[pivot] + ce[j]) {
cost[nx] = cost[pivot] + ce[j];
path[nx] = pivot;
}
}
}
}
}
public static void main(String[] args) throws IOException {
String[] strs = in.readLine().split(" ");
n = Integer.parseInt(strs[0]);
m = Integer.parseInt(strs[1]);
s = Integer.parseInt(strs[2]);
d = Integer.parseInt(strs[3]);
for (int i = 0; i < m; i++) {
strs = in.readLine().split(" ");
a = Integer.parseInt(strs[0]);
b = Integer.parseInt(strs[1]);
w = Integer.parseInt(strs[2]);
c = Integer.parseInt(strs[3]);
insert(a, b, w, c);
insert(b, a, w, c);
}
dijkstra();
//输出
List<Integer> p = new ArrayList<>();
for (int i = d; i != -1 ; i = path[i]) p.add(i);
for (int i = p.size() - 1; i >= 0; i--)
out.write(String.format("%d ",p.get(i)));
out.write(String.format("%d %d", dist[d], cost[d]));
in.close();
isr.close();
out.flush();
out.close();
osw.close();
}
}