#include // #include using namespace std; // using namespace atcoder; using lint = long long; using graph = vector>; #define endl '\n' lint const mod = 1e9+7; //long const mod = 998244353; int main(){ int n,m; cin >> n >> m; int a[m],b[m],c[m]; vector>dist(n); for(int i=0;i> a[i] >> b[i] >> c[i]; a[i]--; b[i]--; dist[a[i]][b[i]] = c[i]; dist[b[i]][a[i]] = c[i]; } vector> ans(n,vector(2,1<<30)); // ans[0][1] = 0; priority_queue , vector>, greater>>que; // cost, v, state dist[0][0] = 0; que.push({0,0,0}); while(!que.empty()){ lint cost = que.top()[0]; lint v = que.top()[1]; lint state = que.top()[2]; que.pop(); if(cost >= ans[v][state])continue; ans[v][state] = cost; for(auto e: dist[v]){ lint nv = e.first; lint ncost = e.second; que.push({cost + ncost, nv, state}); if(state == 0){ que.push({cost, nv, 1}); } } } for(int i=0;i