def dist(p0, p1)
  Math.sqrt( (p0[0] - p1[0]) ** 2 + (p0[1] - p1[1]) ** 2 )
end

def find(x)
  x == $sibling[x] ? x : $sibling[x] = find($sibling[x])
end

n, m = gets.split.map(&:to_i)
$sibling = Array.new(n + 1) { |i| i }
p = [0, *n.times.map { gets.split.map(&:to_f) }]
q = m.times.map { gets.split.map(&:to_i) }
q = q.map{ |a, b| [a, b, dist(p[a], p[b])] }
sum = q.map{ |_, _, d| d }.reduce(:+)
until q.empty?
  ps = q.max{ |a, b| a[2] <=> b[2] }
  q.delete(ps)
  p1, p2, d = ps
  if ( p1 = find(p1) ) != ( p2 = find(p2) )
    $sibling[p2] = p1
    sum -= d
  end
end
p sum < 0 ? 0 : sum