There are N cities and M bus routes, each running from one city to another. A route is written as three integers A, B, C, where A is the departure city, B is the arrival city, and C is the time the ride takes.
The time C is not always positive. When C=0 the ride is instant, and when C<0 the bus is a time machine that sends you back in time.
Write a program that finds the fastest time to travel from city 1 to every other city.