#include <bits/stdc++.h>
const int N = 200005;
using namespace std;
vector<int> g[N];
int t, n, m, a, b, c, dist[3][N];
void dfs(int ind, int st) {
  deque<int> dq = {st};
  dist[ind][st] = 0;
  while (dq.size()) {
    int u = dq.front();
    dq.pop_front();
    for (auto v : g[u]) {
      if (dist[ind][u] + 1 < dist[ind][v]) {
        dist[ind][v] = dist[ind][u] + 1;
        dq.push_back(v);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    vector<long long> ps(m), sm(m + 1);
    for (int i = 0; i < n + 1; i++) {
      g[i] = {};
      dist[0][i] = dist[1][i] = dist[2][i] = INT_MAX;
    }
    for (int i = 0; i < m; i++) cin >> ps[i];
    sort(ps.begin(), ps.end());
    for (int i = 1; i <= m; i++) sm[i] = sm[i - 1] + ps[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);
    }
    dfs(0, a);
    dfs(1, b);
    dfs(2, c);
    long long ans = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
      int e = dist[1][i];
      int r = dist[0][i] + dist[1][i] + dist[2][i];
      if (r > m) continue;
      ans = min(ans, sm[e] + sm[r]);
    }
    cout << ans << '\n';
  }
  return 0;
}
