#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
void dist(int u, vector<int> &du) {
  queue<int> q;
  du[u] = 0;
  q.push(u);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < g[v].size(); i++) {
      int tmp = g[v][i];
      if (du[tmp] == INT_MAX) {
        du[tmp] = du[v] + 1;
        q.push(tmp);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    --a;
    --b;
    --c;
    long long int p[m];
    for (int i = 0; i < m; i++) cin >> p[i];
    sort(p, p + m);
    long long int pref[m + 1];
    memset(pref, 0, sizeof(pref));
    for (int i = 0; i < m; i++) pref[i + 1] = pref[i] + p[i];
    g = vector<vector<int> >(n);
    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      --x;
      --y;
      g[x].push_back(y);
      g[y].push_back(x);
    }
    vector<int> da(n, INT_MAX), db(n, INT_MAX), dc(n, INT_MAX);
    dist(a, da);
    dist(b, db);
    dist(c, dc);
    long long int ans = 1e18;
    for (int i = 0; i < n; i++) {
      if (da[i] + db[i] + dc[i] > m) continue;
      ans = min(ans, pref[db[i]] + pref[da[i] + db[i] + dc[i]]);
    }
    cout << ans << '\n';
  }
  return 0;
}
