#include <bits/stdc++.h>
using namespace std;
const long long inf = 2000000000000000000LL;
long long parent[200010], vis[200010], dis[200010][3];
vector<long long> edges[200010];
vector<long long> p;
void bfs(long long s, long long bal) {
  long long temp, i;
  queue<long long> q;
  dis[s][bal] = 0;
  vis[s]++;
  q.push(s);
  while (q.size()) {
    temp = q.front();
    q.pop();
    for (i = 0; i < edges[temp].size(); i++) {
      long long v = edges[temp][i];
      if (!vis[v]) {
        vis[v]++;
        q.push(v);
        dis[v][bal] = dis[temp][bal] + 1;
      }
    }
  }
}
long long fun(long long a, long long b, long long c) {
  if (a + c + b > p.size()) return inf;
  long long temp = 0;
  if (a + c + b) temp += p[a + b + c - 1];
  if (b) temp += p[b - 1];
  return temp;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, n, m, i, j, k, l, temp, flag, len, shit, q, res, ans, a, b, c;
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    p.clear();
    for (i = 0; i < m; i++) {
      cin >> temp;
      p.push_back(temp);
    }
    sort(p.begin(), p.end());
    for (i = 1; i < m; i++) {
      p[i] += p[i - 1];
    }
    for (i = 1; i <= n; i++) {
      edges[i].clear();
      vis[i] = 0;
    }
    for (i = 0; i < m; i++) {
      cin >> j >> k;
      edges[j].push_back(k);
      edges[k].push_back(j);
    }
    bfs(a, 0);
    for (i = 1; i <= n; i++) vis[i] = 0;
    bfs(b, 1);
    for (i = 1; i <= n; i++) vis[i] = 0;
    bfs(c, 2);
    ans = inf;
    for (i = 1; i <= n; i++) {
      temp = fun(dis[i][0], dis[i][1], dis[i][2]);
      ans = min(ans, temp);
    }
    cout << ans << "\n";
  }
}
