King Byteasar wants the sights of Byteotia to draw crowds of tourists who spend a lot of money that eventually reaches the royal treasury. Reality falls short of his dream. The king told his councilor to look into it, and the councilor found that foreigners stay away from Byteotia because its road network is sparse.
Byteotia has n towns joined by m two-way roads, and every road links two different towns. Some roads run over flyovers or through tunnels. There is no guarantee that every town can be reached from every other town.
The councilor also observed that the current road network allows no long journey. Wherever you start, you cannot visit more than 10 towns without passing through some town twice.
The treasury cannot pay for new roads, so Byteasar decided to build tourist information points (TIPs) instead, staffed by officers who advertise the short trips that are available. For each town there must be a TIP either in that town or in one of the towns linked to it by a road. The cost of building a TIP is known for each town. Find the cheapest way of building TIPs that satisfies the condition.
The first line contains two integers n and m separated by a single space (2≤n≤20000, 0≤m≤25000), the number of towns and the number of roads in Byteotia. The towns are numbered from 1 to n.
The second line contains n integers c1,c2,…,cn separated by single spaces (0≤ci≤10000), where ci is the cost of building a TIP in town i.
Each of the next m lines describes one road. The i-th of these lines contains two integers ai and bi separated by a single space (1≤ai<bi≤n), which means that towns ai and bi are linked by a road. There is at most one road between any pair of towns.
In tests worth 20% of the total score, n≤20 holds.
Print one integer on a single line: the total cost of building all the TIPs.
In the first example the cheapest choice is to build TIPs in towns 1, 5, and 6, at a cost of 3+2+2=7.
