#SDNU1223. Tom'problem A
Tom'problem A
Description
In the future ,One day, tom feel so happy ,because he have a date with a girl,but they don't live in the same city , so tom want you help him find the fastest way to the girl's city,You should note that with the development of technology, transport can go beyond the speed of light, so the time you spend would be less than zero, but if you return to the past you can not have the date with the girl,there city in this country and three are roads in this country;
Tom in the first city,the girl in the city ;
Format
Input
The fist line is ;
Next lines is ( is the name of city , is the time you cost from city to city )
Output
The shortest time to reach the girl’s city
(if tom return to the past ,out )
Samples
1 2
1 2 10
3 4
1 2 10
2 3 10
3 4 -5
10
IMPOSSIBLE!