#include using namespace std; typedef pair pii; int nodeCount, edgeCount; void dijkstra(int src, vector>G[1005], int dist[]) { priority_queue, greater >pq; pq.push({0, src}); dist[src] =0; while(!pq.empty()) { int u = pq.top().second; pq.pop(); int sz = G[u].size(); for(auto v: G[u]) { int cost = dist[u] + v[1]; if(dist[v[0]] > cost) { dist[v[0]]=cost; pq.push({cost, v[0]}); } } } } int main() { cin>>nodeCount>>edgeCount; int dist[nodeCount]; vector>G[1005]; for(int i=1; i<=nodeCount; i++) { dist[i]=INT_MAX/2; } for(int i=1; i<=edgeCount; i++) { int u,v,weight; cin>>u>>v>>weight; G[u].push_back({v,weight}); G[v].push_back({u,weight}); } dijkstra(0,G,dist); for(int i=0; i<=nodeCount; i++) cout << dist[i]; return 0; }