#include <bits/stdc++.h>
using namespace std;
vector<int> BFS(int n, int src, vector<vector<int> > &AdjList) {
  vector<int> dist(n, 1e9);
  queue<int> q;
  dist[src] = 0;
  q.push(src);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : AdjList[u]) {
      if (dist[v] == 1e9) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
  return dist;
}
int main() {
  int Tc;
  cin >> Tc;
  while (Tc--) {
    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    a--, b--, c--;
    vector<long long> p(m), Pref(m + 1);
    vector<vector<int> > AdjList(n, vector<int>());
    for (int i = 0; i < m; i++) cin >> p[i];
    sort(p.begin(), p.end());
    for (int i = 0; i < m; i++) Pref[i + 1] = Pref[i] + p[i];
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      AdjList[--u].push_back(--v);
      AdjList[v].push_back(u);
    }
    vector<int> distA = BFS(n, a, AdjList), distB = BFS(n, b, AdjList),
                distC = BFS(n, c, AdjList);
    long long Ans = 1e18;
    for (int x = 0; x < n; x++) {
      if (distA[x] + distB[x] + distC[x] <= m)
        Ans = min(Ans, Pref[distB[x]] + Pref[distA[x] + distB[x] + distC[x]]);
    }
    cout << Ans << endl;
  }
  return 0;
}
