#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 8;
const long long INF = (long long)1e18;
vector<vector<long long>> g(N);
vector<long long> p(N), pref(N);
long long n, m, a, b, c;
void BFS(long long v, vector<long long> &d) {
  d.resize(n, -1);
  d[v] = 0;
  queue<pair<long long, long long>> q;
  q.emplace(d[v], v);
  while (!q.empty()) {
    pair<long long, long long> t = q.front();
    q.pop();
    long long x = t.second;
    for (long long to : g[x]) {
      if (d[to] != -1) {
        continue;
      }
      d[to] = d[x] + 1;
      q.emplace(d[to], to);
    }
  }
}
long long sum(long long x) {
  if (x > m) {
    return INF;
  }
  if (x <= 0) {
    return 0;
  } else {
    return pref[x - 1];
  }
}
long long solve() {
  cin >> n >> m >> a >> b >> c;
  --a, --b, --c;
  for (long long i = 0; i < m; ++i) {
    cin >> p[i];
  }
  sort(p.begin(), p.begin() + m);
  pref[0] = p[0];
  for (long long i = 1; i < m; ++i) {
    pref[i] = pref[i - 1] + p[i];
  }
  for (long long i = 0; i < m; ++i) {
    long long v, u;
    cin >> v >> u;
    --v, --u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  vector<long long> d1, d2, d3;
  BFS(a, d1);
  BFS(b, d2);
  BFS(c, d3);
  long long ans = 2 * pref[m - 1];
  long long now = 0;
  for (long long d = 0; d < n; ++d) {
    long long x = d1[d], y = d2[d], z = d3[d];
    now = sum(x + y + z) + sum(y);
    ans = min(ans, now);
  }
  for (long long i = 0; i < n; ++i) {
    g[i].clear();
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T;
  cin >> T;
  while (T--) {
    cout << solve() << '\n';
  }
  return 0;
}
