#include <bits/stdc++.h>
using namespace std;
vector<long long> bfs(vector<long long> adj[], long long src, long long n) {
  vector<long long> dist(n, 1000000000);
  dist[src] = 0;
  queue<long long> q;
  q.push(src);
  while (!q.empty()) {
    long long x = q.front();
    q.pop();
    for (auto i : adj[x]) {
      if (dist[i] == 1000000000) {
        dist[i] = dist[x] + 1;
        q.push(i);
      }
    }
  }
  return dist;
}
int32_t main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j;
  long long t;
  cin >> t;
  while (t--) {
    long long n, m, a, b, c;
    cin >> n >> m >> a >> b;
    cin >> c;
    --a;
    --b;
    --c;
    long long p[m];
    for (i = 0; i < m; i++) cin >> p[i];
    sort(p, p + m);
    long long pre[m + 1];
    pre[0] = 0;
    for (i = 0; i < m; i++) pre[i + 1] = pre[i] + p[i];
    vector<long long> adj[n];
    for (i = 0; i < m; i++) {
      long long u, v;
      cin >> u >> v;
      --u;
      --v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    vector<long long> d1 = bfs(adj, a, n);
    vector<long long> d2 = bfs(adj, b, n);
    vector<long long> d3 = bfs(adj, c, n);
    long long ans = LONG_LONG_MAX;
    for (i = 0; i < n; i++) {
      if (d1[i] + d2[i] + d3[i] > m) continue;
      ans = min(ans, pre[d2[i]] + pre[d2[i] + d1[i] + d3[i]]);
    }
    cout << ans << "\n";
  }
  return 0;
}
