# [Poi2014]Tourism

时间限制：20s 空间限制：256MB

### 题目描述

King Byteasar believes that Byteotia, a land full of beautiful sights, should attract lots of tourists, who should spend lots of money, which should eventually find their way to the royal treasury. But reality does not live up to his dream. So the king instructed his councilor to look into this issue. The councilor found out that foreigners keep away from Byteotia due to its sparse road network.

Let us remark that there are towns in Byteotia, connected by two way roads, each road linking two different towns. The roads may lead through picturesque overflies and somewhat less picturesque tunnels. There is no guarantee that every town can be reached from every other town.

The councilor observed that the current road network does not allow for a long journey. Namely, wherever one starts the journey, it is impossible to visit more than 10 towns without passing through some town twice.

Due to limited funds in the treasury, no new roads will be constructed at the time. Instead, Byteasar has decided to build a network of tourist information points (TIPs), staffed by officers who are to advertise the short trips that are available. For each town, there should be a TIP either in this town or one of the towns directly linked by a road. Moreover, the cost of building the TIP is known for each town. Help the king by finding the cheapest way of building TIPs that will satisfy aforementioned condition.

给定一个n个点，m条边的无向图，其中你在第i个点建立旅游站点的费用为C[i]。在这张图中，任意两点间不存在节点数超过10的简单路径。

请找到一种费用最小的建立旅游站点的方案，使得每个点要么建立了旅游站点，要么与它有边直接相连的点里至少有一个点建立了旅游站点。

### 输入格式

The first line of the standard input contains two integers N,M(2<=N<=20 000,0<=m<=25000), separated by a single space, that specify the number of towns and roads in Byteotia respectively. The towns are numbered from to n. The second line of input contains n integers C1,C2…Cn(0<=Ci<=10000), separated by single spaces; the number Ci specifies the cost of building a TIP in the town no. i.

Then, a description of the Byteotian road network follows. The i-th of the following m lines contains two integers Ai，Bi(1<=Ai<Bi<=N), separated by a single space, that indicate that the towns no. Ai and Bi are linked by a road. There is at most one (direct) road between any pair of towns.

第一行包含两个正整数n,m(1<=n<=20000,0<=m<=25000)，分别表示点数和边数。

第二行包含n个整数，其中第i个数为C[i](0<=C[i]<=10000)，表示在第i个点建立旅游站点的费用。

接下来m行，每行两个正整数u,v(1<=u,v<=n)，表示u与v之间连了一条边，保证没有重边

### 输出格式

Your program should print out one integer to the standard output: the total cost of building all the TIPs.

输出一行一个整数，即最小的总费用。

### 样例输入

6 6 3 8 5 6 2 2 1 2 2 3 1 3 3 4 4 5 4 6

### 样例输出

7

### 提示

Explanation: To attain the minimum, the TIPs should be built in towns no. 1, 5, and 6. (the cost will be ).

分别在1，5，6号站点建立旅游站点。

### 题目来源

没有写明来源