COVID-19 outbreak in Atlantis is so bad that the government is forced to lock down the whole country. Athens, the capital of Atlantis is an overpopulated city. The situation here is very severe. People are having a shortage of food as a result of the lockdown. So, all other cities decided to send food to Athens by trucks.
There are cities in Atlantis. They are connected through bi-directed roads. It is possible to reach from any city to another using exactly one path. Cities are numbered from 1 to . The city Athens is numbered by an integer . For each i from 1 to there are food trucks in city .
Due to the lockdown, no road is allowed to pass more than trucks. This limit of differs from road to road. You have to find the maximum total number of food trucks Athens can have, if every city sends food trucks in the optimal way.
First line of input contains two integers and (). Each of the next lines contains three integers , () and () meaning there is a road between city and and the capacity of that road is . Next line contains N integers (). The integer indicates the number of food trucks in the city .
Print one integer, the maximum possible number of food trucks that Athens can have.
Input | Output |
---|---|
5 1 1 4 3 1 2 6 2 5 10 2 3 2 7 4 6 5 2 | 16 |