#include using namespace std; template using priority_queue_reverse = priority_queue,greater>; int main() { cin.tie(0);ios::sync_with_stdio(false); int N,M,S,G; cin >> N >> M >> S >> G; vector>> edge(N); for(int i=0;i> a >> b >> c; edge[a].push_back({b,c}); edge[b].push_back({a,c}); } for(int i=0;i dp(N,inf); priority_queue_reverse> pq; dp[G]=0; pq.push({0,G}); while(pq.size()) { auto p = pq.top(); pq.pop(); int from = p.second; if(p.first > dp[from]) continue; for(auto q:edge[from]) { int to = q.first; if(dp[to] > dp[from]+q.second) { dp[to] = dp[from]+q.second; pq.push({dp[to],to}); } } } vector ans = {S}; int sum = 0; while(ans.back()!=G) { int from = ans.back(); for(auto q:edge[from]) { int to = q.first; if(sum + q.second + dp[to] == dp[S]) { ans.push_back(to); sum += q.second; break; } } } for(int i=0;i