#ifndef ONLINE_JUDGE // #define _GLIBCXX_DEBUG #endif #include #include using namespace std; using ll=long long; using ld=long double; using st=string; using P=pair; typedef atcoder::modint mint; ll inf=9e18; template auto vec(const ll (&sizes)[s], const T& init = T()){ if constexpr(i < s) return vector(sizes[i], vec(sizes, init)); else return init; } struct Edge{ll to,cost=1;}; bool operator>(Edge a,Edge b){ return a.cost>b.cost; } vector a0,a1,a2; void dijkstra(vector> &graph,ll s,vector &dis){ priority_queue,greater> q; dis=vector(graph.size(),inf); q.push({s,a0[s]}); dis[s]=a0[s]; while(!q.empty()){ ll f=q.top().to,c=q.top().cost; // cout<>n>>m; auto w=vec({n,0},{0,0}); a0=vec({n},0); a1=vec({n},0); a2=vec({n},0); for(ll i=0;i>u>>v>>c; w[--u].push_back({--v,c}); w[v].push_back({u,c}); } for(ll i=0;i>a0[i]; for(ll i=0;i>a1[i]; for(ll i=0;i>a2[i]; auto dis=vec({n},0); dijkstra(w,0,dis); cout<