#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
void bfs(int src, vector<int> &v) {
  v[src] = 0;
  queue<int> q;
  q.push(src);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto i : adj[x]) {
      if (v[i] == -1) {
        v[i] = v[x] + 1;
        q.push(i);
      }
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    --a, --b, --c;
    vector<int> p(m);
    for (auto &it : p) cin >> it;
    sort(p.begin(), p.end());
    adj = vector<vector<int>>(n);
    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      --x;
      --y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    vector<long long> pref(m + 1);
    for (int i = 1; i <= m; i++) {
      pref[i] = pref[i - 1] + p[i - 1];
    }
    vector<int> pa(n, -1), pb(n, -1), pc(n, -1);
    bfs(a, pa);
    bfs(b, pb);
    bfs(c, pc);
    long long ans = 1e18;
    for (int i = 0; i < n; i++) {
      if (pa[i] + pb[i] + pc[i] > m) continue;
      ans = min(ans, pref[pb[i]] + pref[pa[i] + pb[i] + pc[i]]);
    }
    cout << ans << "\n";
  }
}
