A country is at war, and one of its messenger soldiers must transport something of great importance from city 1 to city 2 using the highway system, which consists entirely of one-way highways. As soon as the soldier sets out on his mission, he is informed by an agent that the enemy has destroyed exactly one of the highways in the country. Unfortunately, it is unknown which highway was destroyed. He won't know which highway was destroyed until he arrives at the starting city of the destroyed highway. The soldier wants to use a strategy that will make the worst-case distance he has to travel as short as possible.
You are given an int n, the number of cities in the country. The cities are numbered 1 to n. The highways between cities are given in the String highways. Concatenate the elements of highways to get a comma separated list of integer triplets. Each triplet is formatted "a b c" (quotes for clarity), which means that there's a one-way highway of length c from city a to city b. Return the distance the messenger soldier will have to travel in the worst case. If there is a chance that he will never reach his destination, return -1 instead.
|-||Note that there may be multiple parallel highways from one city to another.|
|-||n will be between 2 and 100, inclusive.|
|-||highways will contain between 1 and 50 elements, inclusive.|
|-||Each element of highways will contain between 1 and 50 characters, inclusive.|
|-||When concatenated, highways will contain a comma separated list of triplets of integers.|
|-||Each integer triplet will be formatted "a b c" (quotes for clarity), where a and b are distinct integers between 1 and n, inclusive, and c is an integer between 1 and 1000, inclusive.|
|-||Each integer in integer triplets will have no leading zeros and will contain only digits ('0'-'9').|