#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int p[maxn], d[maxn][3], vis[maxn];
long long sum[maxn];
vector<int> g[maxn];
void bfs(int s, int id) {
  queue<int> que;
  while (!que.empty()) que.pop();
  que.push(s), d[s][id] = 0;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (auto v : g[u])
      if (!d[v][id] && v != s) {
        que.push(v);
        d[v][id] = d[u][id] + 1;
      }
  }
}
int main() {
  int T;
  for (scanf("%d", &T); T; T--) {
    int n, m, a, b, c;
    scanf("%d%d%d%d%d", &n, &m, &a, &b, &c);
    for (int i = 1; i <= m; i++) scanf("%d", &p[i]);
    for (int i = 1; i <= m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      g[u].push_back(v);
      g[v].push_back(u);
    }
    sort(p + 1, p + 1 + m);
    bfs(a, 0), bfs(b, 1), bfs(c, 2);
    long long ans = 1e18;
    for (int i = 1; i <= m; i++) sum[i] = sum[i - 1] + p[i];
    for (int i = 1; i <= n; i++) {
      if (d[i][0] + d[i][1] + d[i][2] > m) continue;
      ans = min(ans, sum[d[i][1]] + sum[d[i][0] + d[i][1] + d[i][2]]);
    }
    printf("%lld\n", ans);
    for (int i = 1; i <= n; i++) g[i].clear();
    for (int i = 1; i <= n; i++) d[i][0] = d[i][1] = d[i][2] = 0;
  }
  return 0;
}
