#Lutece0444. Earthquake
Earthquake
Migrated from Lutece 444 Earthquake
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Just a week before,the people in Japan suffered from the heavy earthquake which is estimated to be Richter 9
It brought tremendous impact on the people's security,country's economy and some other aspects.
Admittedly,human beings don't own the ability to take control of the nature,however,if effective treasures are taken,
we can reduce the damage caused by natural disasters to its lowest.
Here,a plan is proposed.That is we want to found stations in cities in order to store enough food,water and some other necessities.
Storing enough resource in a city in advance,we are able to supply this city and other cities adjacent to this one when an earthquake occurs.But founding such a station costs a lot,taking all factors into account.Influenced by the city's location,economy,politics and other factors,founding the station costs differently in different cities.Aiming to use the least money to make sure all cities can be supplied,the controller of the project asking you for help.Note that it's allowed a city can be supplied by different stations.
Input
Multiple test cases ended with EOF
Each test case starts with two integers (number of cities,) (number of relations between two cities,)
Next line are integers ( indicating the cost for building a station in city , )
Following are lines,each line includes two integers , ( , indicating city is adjacent to city )
Output
A single integer,indicating the minimum cost
Samples
3 2
40 10 20
1 2
1 3
7 5
100 23 41 19 15 20 1
1 2
1 3
1 4
5 6
5 7
30
98
Note
Pay attention! It's assured that no circles exist.
Resources
5th BUPT Programming Contest Final