#include #include #include #include using namespace std; using ll = long long; const int MAXLL=8e18; int main(){ int N,M; cin >> N >> M; vector>> edge(N+1); for(int i=0;i> U >> V >> W; edge[U].push_back({V,W}); edge[V].push_back({U,W}); } vector A(N+1,0); for(int i=1;i<=N;i++){ cin >> A[i]; } return 0; vector visited(N+1,MAXLL); priority_queue, vector>, greater>> q; q.push({0LL,1}); while(!q.empty()){ auto [c,now]=q.top(); q.pop(); if(visited[now]>c){ visited[now]=c; for(int i=0;it+edge[now][next].second){ q.push({t+edge[now][next].second,next}); } } } } if(visited[N]==MAXLL){ cout << -1 << "\n"; }else{ cout << visited[N] << "\n"; } return 0; }