inf = 10**9 def dijkstra(s): used = [False]*N d = [inf]*N d[s] = 0 while 1: v = -1 for u in xrange(N): if not used[u] and (v == -1 or d[u] < d[v]): v = u if v == -1: break used[v] = True for u in xrange(N): d[u] = min(d[u], d[v]+cost[v][u]) return d[G] def dfs(path,t): if path[-1] == G: return path spath = set(path) res = [] for i in xrange(N): if i not in spath and t+cost[i][path[-1]] <= time: res = dfs(path+[i],t+cost[i][path[-1]]) if res: return res return [] N,M,S,G = map(int,raw_input().split()) cost = [[inf]*N for i in xrange(N)] for loop in xrange(M): a,b,c = map(int,raw_input().split()) cost[a][b] = cost[b][a] = c time = dijkstra(S) print " ".join(map(str,dfs([S],0)))