热浪
#include<iostream>
#include<cstring>
#include<cmath>
#define inf 0x3f3f3f3f
using namespace std;
const int N=2505;
int mapp[N][N],dis[N];
bool vis[N];
int main(){
int n,m,s,e;
cin>>n>>m>>s>>e;
memset(mapp,inf,sizeof(mapp));
while(m--){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
mapp[a][b]=mapp[b][a]=c;
}
for(int i=1;i<=n;i++)
dis[i]=mapp[s][i];
memset(vis,false,sizeof(vis));
dis[s]=0,vis[s]=true;
for(int i=1;i<n;i++){
int minn=inf;
int k=0;
for(int j=1;j<=n;j++){
if(!vis[j]&&minn>dis[j]){
minn=dis[j];
k=j;
}
}
if(!k)break;
vis[k]=true;
for(int j=1;j<=n;j++)
dis[j]=min(dis[j],dis[k]+mapp[k][j]);
}
cout<<dis[e];
return 0;
}