def max_heapify(x = 1)
  l = 2*x
  r = 2*x+1
  if l <= $n && $heap[l][0] > $heap[x][0]
    maximum = l
  else
    maximum = x
  end
  if r <= $n && $heap[r][0] > $heap[maximum][0]
    maximum = r
  end
  if maximum != x
    $heap[x], $heap[maximum] = $heap[maximum], $heap[x]
    max_heapify(maximum)
  end
end

def extract
  key = $heap[1]
  $heap[1] = $heap[$n]
  $n -= 1
  max_heapify
  key
end

def insert(key)
  $n += 1
  $heap[$n] = key
  i = $n
  while i > 1 && $heap[i/2][0] < $heap[i][0]
    $heap[i], $heap[i/2] = $heap[i/2], $heap[i]
    i /= 2
  end
end

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) }
sum = 0
$n = 0
$heap = []
q.each do |a, b|
  insert( [dist(p[a], p[b]), a, b] )
end
until $n < 1
  d, p1, p2 = extract
  if ( p1 = find(p1) ) != ( p2 = find(p2) )
    $sibling[p2] = p1
  else
    sum += d
  end
end
p sum < 0 ? 0 : sum