#include #include #include using namespace std; int n,m; vector > adj[10000]; int d[10000]; int main() { freopen("test.in","r",stdin); scanf("%d %d",&n,&m); for (int i=0;i > pq; pq.push({0,1}); while (!pq.empty()) { pair p=pq.top(); pq.pop(); int x=p.second, dx=-p.first; if (dx!=d[x]) continue; for (pair yc : adj[x]) { int y=yc.first, c=yc.second; if (d[x]+c