#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
void bfs_trvrsl(int u, vector<int>& cnt, queue<int>& Q) {
  for (int v : g[u]) {
    if (cnt[v] == -1) {
      cnt[v] = cnt[u] + 1;
      Q.push(v);
    }
  }
}
void bfs(int u, vector<int>& cnt) {
  queue<int> Q;
  Q.push(u);
  cnt[u] = 0;
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    bfs_trvrsl(v, cnt, Q);
  }
}
int main(int argc, char** argv) {
  int t;
  cin >> t;
  while (t--) {
    int n, m, a, b, c;
    vector<unsigned long long> prc;
    vector<int> cnta;
    vector<int> cntb;
    vector<int> cntc;
    cin >> n >> m >> a >> b >> c;
    g = vector<vector<int>>(n + 1);
    prc = vector<unsigned long long>(m + 1, 0);
    cnta = vector<int>(n + 1, -1);
    cntb = vector<int>(n + 1, -1);
    cntc = vector<int>(n + 1, -1);
    for (int i = 1; i <= m; i++) cin >> prc[i];
    sort(prc.begin() + 1, prc.end());
    for (int i = 1; i <= m; i++) prc[i] += prc[i - 1];
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    bfs(a, cnta);
    bfs(b, cntb);
    bfs(c, cntc);
    unsigned long long ans = (unsigned long long)pow(10, 63);
    ;
    for (int i = 1; i <= n; i++) {
      if (cnta[i] + cntb[i] + cntc[i] <= m) {
        ans = min(ans, prc[cntb[i]] + prc[cnta[i] + cntb[i] + cntc[i]]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
