#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
vector<vector<long long> > adj;
vector<long long> bfs(long long src, long long n) {
  queue<long long> q;
  q.push(src);
  vector<long long> dist(n + 1, -1);
  dist[src] = 0;
  while (!q.empty()) {
    long long x = q.front();
    q.pop();
    for (long long v : adj[x]) {
      if (dist[v] == -1) {
        dist[v] = dist[x] + 1;
        q.push(v);
      }
    }
  }
  return dist;
}
void solve() {
  long long n, m, a, b, c, u, v;
  cin >> n >> m >> a >> b >> c;
  vector<long long> p(m + 1);
  for (long long i = 1; i < m + 1; i++) cin >> p[i];
  sort(p.begin(), p.end());
  adj.clear();
  adj.resize(n + 1);
  for (long long i = 1; i <= m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  vector<long long> A = bfs(a, n);
  vector<long long> B = bfs(b, n);
  vector<long long> C = bfs(c, n);
  vector<long long> pre(m + 1, 0);
  for (long long i = 1; i <= m; i++) {
    pre[i] = pre[i - 1] + p[i];
  }
  long long output = LLONG_MAX;
  for (long long i = 1; i <= n; i++) {
    long long x = A[b], y = B[i], z = C[i], q = A[i], r = B[i];
    if (x + z > m) continue;
    if (q + z + r > m) continue;
    long long ans = pre[q + z + r] + pre[r];
    output = min(output, ans);
  }
  cout << output << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
