#include <iostream> #include <cstdio> #include <queue> using namespace std; const int maxn=6210; const int INF=1<<30; int n,c,s,t,d[2510]; bool vis[2510]; struct edge{int v,w;}; queue<int> q; vector<edge> G[maxn]; void spfa(){ for(int i=1;i<=n;i++)d[i]=INF; q.push(s); d[s]=0; vis[s]=1; while(!q.empty()){ int u=q.front(); q.pop(); vis[u]=0; for(int i=0;i<G[u].size();i++){ int v=G[u][i].v,w=G[u][i].w; if(d[u]+w<d[v]){ d[v]=d[u]+w; if(!vis[v]){q.push(v); vis[v]=1;} } } } } int main(){ scanf("%d%d%d%d",&n,&c,&s,&t); while(c--){ int u,v,w; scanf("%d%d%d",&u,&v,&w); G[u].push_back((edge){v,w}); G[v].push_back((edge){u,w}); } spfa(); printf("%d ",d[t]); return 0; }