#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 2e5 + 5;
long long t, n, m, u, v, a, b, c, p[N], d[N][3];
vector<int> edges[N];
bool vis[N];
void in() {
  for (int i = 0; i <= n; i++) edges[i].clear();
}
void bfs(int node, int idx) {
  for (int i = 1; i <= n; i++) vis[i] = d[i][idx] = 0;
  queue<pair<int, int> > Q;
  Q.push({node, 0}), vis[node] = 1;
  while (!Q.empty()) {
    node = Q.front().first;
    int lvl = Q.front().second;
    d[node][idx] = lvl;
    Q.pop();
    for (auto i : edges[node]) {
      if (vis[i]) continue;
      Q.push({i, lvl + 1});
      vis[i] = 1;
    }
  }
}
long long solve(int x) {
  if (d[x][0] + d[x][1] + d[x][2] - 1 >= m) return 1e18;
  p[-1] = 0;
  return p[d[x][0] + d[x][1] + d[x][2] - 1] + p[d[x][1] - 1];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    in();
    cin >> n >> m >> a >> b >> c;
    for (int i = 0; i < m; i++) cin >> p[i];
    for (int i = 0; i < m; i++) {
      cin >> u >> v;
      edges[u].push_back(v);
      edges[v].push_back(u);
    }
    sort(p, p + m);
    for (int i = 1; i < m; i++) p[i] += p[i - 1];
    bfs(a, 0), bfs(b, 1), bfs(c, 2);
    long long ans = 1e15;
    for (int i = 1; i <= n; i++) ans = min(ans, solve(i));
    cout << ans << '\n';
  }
  return 0;
}
