#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int maxn = 2e5 + 5;
int p[maxn];
long long prefix[maxn];
vector<int> v[maxn];
int n, m, a, b, c;
int dis[4][maxn];
queue<int> q;
void bfs(int st, int pos) {
  while (!q.empty()) q.pop();
  q.push(st);
  for (int i = 1; i <= n; i++) dis[pos][i] = -1;
  dis[pos][st] = 0;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < v[x].size(); i++) {
      if (dis[pos][v[x][i]] != -1) continue;
      dis[pos][v[x][i]] = dis[pos][x] + 1;
      q.push(v[x][i]);
    }
  }
}
void test() {
  cin >> n >> m >> a >> b >> c;
  for (int i = 1; i <= n; i++) v[i].clear();
  for (int i = 1; i <= m; i++) cin >> p[i];
  sort(p + 1, p + 1 + m);
  for (int i = 1; i <= m; i++) prefix[i] = prefix[i - 1] + p[i];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  bfs(a, 0);
  bfs(b, 1);
  bfs(c, 2);
  long long ans = inf;
  for (int i = 1; i <= n; i++) {
    int cnt1 = dis[1][i], cnt2 = dis[0][i] + dis[2][i];
    if (cnt1 + cnt2 <= m) ans = min(ans, prefix[cnt1] + prefix[cnt1 + cnt2]);
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) test();
  return 0;
}
