#include <bits/stdc++.h>
using namespace std;
long long fpow(long long n, long long k, long long p = 1000000007) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
long long inv(long long a, long long p = 1000000007) {
  return fpow(a, p - 2, p);
}
long long power(long long x, long long y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long n, m;
vector<long long> v[200001];
vector<int> bfs(int node) {
  bool visit[n + 1];
  vector<int> length(n + 1, 0);
  memset(visit, 0, sizeof(visit));
  queue<int> q;
  q.push(node);
  while (!q.empty()) {
    int front = q.front();
    visit[front] = 1;
    q.pop();
    for (long long i = (0); i < (v[front].size()); i++) {
      if (visit[v[front][i]] == 0) {
        q.push(v[front][i]);
        length[v[front][i]] = length[front] + 1;
        visit[v[front][i]] = 1;
      }
    }
  }
  return length;
}
int main() {
  long long j, k, t, a, b, c, x, y;
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    long long p[m + 1];
    for (long long i = (1); i < (m + 1); i++) cin >> p[i];
    sort(p + 1, p + m + 1);
    long long pref[m + 1];
    pref[0] = 0;
    for (long long i = (1); i < (m + 1); i++) pref[i] = pref[i - 1] + p[i];
    for (long long i = (0); i < (m); i++) {
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    vector<int> length1 = bfs(a);
    vector<int> length2 = bfs(b);
    vector<int> length3 = bfs(c);
    long long ans = 1e18;
    for (long long i = (1); i < (n + 1); i++) {
      if (length1[i] + length2[i] + length3[i] <= m) {
        long long temp =
            pref[length1[i] + length2[i] + length3[i]] + pref[length2[i]];
        ans = min(ans, temp);
      }
    }
    cout << ans << "\n";
    for (long long i = (1); i < (n + 1); i++) v[i].clear();
  }
  return 0;
}
