#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _MSC_VER #include #endif #define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i) #define rep(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define REV(v) v.rbegin(), v.rend() #define MEMSET(v, s) memset(v, s, sizeof(v)) #define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end()) #define MP make_pair #define MT make_tuple using namespace std; typedef long long ll; typedef long double ld; typedef pair P; const int N = 202; int dist[N][N]; int edge[N][N]; int main(){ cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); int n, m, s, g; cin >> n >> m >> s >> g; rep(i, n) rep(j, n) dist[i][j] = i == j ? 0 : 1e9; rep(i, m){ int a, b, c; cin >> a >> b >> c; edge[a][b] = edge[b][a] = c; dist[a][b] = dist[b][a] = c; } rep(i, n) rep(j, n) rep(k, n) dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]); int pos = s; int x = dist[s][g]; vector ans; while (1){ ans.push_back(pos); if (pos == g) break; rep(i, n){ if (edge[pos][i] && edge[pos][i] + dist[i][g] == x){ x = dist[i][g]; pos = i; break; } } } int k = ans.size(); rep(i, k) cout << ans[i] << " \n"[i == k - 1]; }