LearnPy Hub
← Arena
AdvancedRating 1600

Cheapest Route

Roads 'u v w' are two-way with cost w. Print the cheapest cost from city 1 to every city (-1 if unreachable).

Input

n m, then m lines.

Output

One line.

Sample 1

Input
4 4
1 2 5
1 3 2
3 2 1
2 4 7
Output
0 3 2 10

Sample 2

Input
2 0
Output
0 -1
solution.py
Output appears here
Cheapest Route · Python Arena problem · LearnPy Hub