#include using namespace std; #define all(v) v.begin(),v.end() using ll = long long; using ull = unsigned long long; using vll=vector; const ll INF=1ll<<60; using vp=vector>; using P = pair; using vvll = vector>; ll N,M,p,Q,T; vll dik(ll s,vvll &ab){ vll dist(N,INF); priority_queue,greater

>q; dist[s]=0; q.push({0,s}); while(!q.empty()){ auto x=q.top();q.pop(); if(dist[x.second]>N>>M>>p>>Q>>T; p--;Q--; vvll ab(N); for(int i=0;i>a>>b>>c; a--;b--; ab[a].push_back({c,b}); ab[b].push_back({c,a}); } vll dist=dik(0,ab); vll distp=dik(p,ab); vll distq=dik(Q,ab); ll ans=-1; if(dist[p]+distp[Q]+dist[Q]<=T)ans=max(ans,T); for(int i=0;i