#include #define rep(i,a,b) for(int i=int(a);i P; int INF = (1LL << 30) - 1; int MOD = 1e9+7; int N,M,S,G; int dest[200][200]; int used[200]; stack st; bool dfs(int now, int res){ if(now == G && res == 0){ st.push(now); return true; } rep(i,0,N){ if(i == now || used[i] || res < dest[now][i])continue; used[i] = 1; if(dfs(i, res - dest[now][i])){ st.push(now); return true; } used[i] = 0; } return false; } main(){ cin >> N >> M >> S >> G; P dist[N][N]; rep(i,0,N)rep(j,0,N){ dest[i][j] = INF; dist[i][j] = P(INF, {i, j}); } //rep(i,0,N)dist[i][i].first = 0; int A[M],B[M],C[M]; rep(i,0,M){ cin >> A[i] >> B[i] >> C[i]; dest[A[i]][B[i]] = dest[B[i]][A[i]] = C[i]; dist[A[i]][B[i]].first = dist[B[i]][A[i]].first = C[i]; } rep(i,0,N)rep(j,0,N)rep(k,0,N){ string str = dist[j][i].second + dist[i][k].second.substr(1); //string str = dist[j][i].second + dist[i][k].second; if(dist[j][k].first > dist[j][i].first + dist[i][k].first || dist[j][k].first == dist[j][i].first + dist[i][k].first && dist[j][k].second > str){ dist[j][k].first = dist[j][i].first + dist[i][k].first; dist[j][k].second = str; } } //cout << dist[S][G].second << endl; for(auto c:dist[S][G].second){ cout << (((int)c) + 256 )% 256 << " "; } cout << endl; }