#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int INF = (1 << 30) - 1; const ll INFLL= (1LL << 61) - 1; const int MOD = 1000000007; #define ALL(a) (a).begin(),(a).end() #define rALL(a) (a).rbegin(),(a).rend() template struct Edge { int to; T cost; Edge() {} Edge(int to, T cost) : to(to), cost(cost) {} bool operator>(const Edge &r) const { return this->cost > r.cost; } }; template vector Dijkstra(vector>> &edges, int st) { int V = (int)edges.size(); vector dist(V, INFLL); dist[st] = 0; priority_queue, vector>, greater>> p_que; p_que.emplace(st, dist[st]); while (!p_que.empty()) { Edge now(p_que.top().to, p_que.top().cost); p_que.pop(); if (dist[now.to] < now.cost) continue; for (const Edge &e : edges[now.to]) { T tmp_cost = now.cost + e.cost; if (dist[e.to] > tmp_cost) { dist[e.to] = tmp_cost; p_que.emplace(e.to, dist[e.to]); } } } return dist; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N,M,P,Q,T; cin>>N>>M>>P>>Q>>T; P--;Q--; vector > > edges(N); for(int i=0;i>a>>b>>c; a--; b--; edges[a].emplace_back(b,c); edges[b].emplace_back(a,c); } auto ans1 = Dijkstra(edges,0); auto ansq = Dijkstra(edges,Q); auto ansp = Dijkstra(edges,P); ll p1=ans1[P],q1=ans1[Q],pq=ansq[P]; if(p1*2>T || q1*2>T){ cout<<-1<