#include using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) typedef long long ll; const ll longinf=1LL<<60 ; using G=vector>>; vector bfs(int s,G v){ int n=v.size(); vector dist(n,longinf); dist[s]=0; priority_queue> que; que.emplace(0,s); while(que.size()){ ll d=-que.top().first; int cur=que.top().second; que.pop(); if(d>dist[cur])continue; for(auto e : v[cur]){ if(dist[e.second]>d+e.first){ dist[e.second]=d+e.first; que.emplace(-dist[e.second],e.second); } } } return dist; } int main(){ int n,m,p,q,t; cin>>n>>m>>p>>q>>t; --p;--q; G v(n); rep(i,m){ int a,b,c; cin>>a>>b>>c; --a;--b; v[a].emplace_back(c,b); v[b].emplace_back(c,a); } auto dist_s=bfs(0,v); auto dist_p=bfs(p,v); auto dist_q=bfs(q,v); ll ans=-1; ll ret=dist_s[p]+dist_p[q]+dist_q[0]; if(ret