Time limit
2s
Memory limit
128 MB
Hwang Seon-ja is a channeler who can communicate with space gods. Because there are many space gods, directly communicating with every one of them is exhausting.
Fortunately, every space god does not need a direct connection to Seon-ja. If a space god is already connected to Seon-ja, or can reach Seon-ja through passages connected to other space gods, communication is possible.
Communication happens through mental passages between Seon-ja and a space god, or between two space gods. Longer passages require more effort, so the total length of newly built passages should be as small as possible.
Seon-ja and the space gods live on a 2D coordinate plane. The length of a passage between two beings is the Euclidean distance between their coordinates.
Some passages are already connected. Add passages so that every being belongs to one connected network, while minimizing the total length of the newly added passages.
The first line contains the number of space gods N (1≤N≤1000) and the number of already connected passages M (1≤M≤1000).
Each of the next N lines contains the coordinates X, Y (0≤X,Y≤1000000) of one being, including Seon-ja. The beings are numbered from 1 to N in input order, and all coordinates are integers.
Each of the following M lines contains two numbers that are already connected by a passage.
Print the minimum total length of the passages that must be newly built, rounded to two digits after the decimal point.
Suppose the coordinates are (1,1), (3,1), (2,3), and (4,3), and beings 1 and 4 are already connected. If you additionally connect 1 with 2 and 3 with 4, every being can reach every other being and the total length of the newly built passages is minimized.