#include <bits/stdc++.h>
using namespace std;
const int maxN = 200000 + 5;
const int maxM = 200000 + 5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int head[maxN], nxt[maxM * 2], to[maxM * 2], W[maxM * 2], d[4][maxN], vis[maxN],
    p[maxM];
long long sum[maxM];
int T, n, m, a, b, c, tot;
queue<int> que;
void link(int u, int v) {
  nxt[++tot] = head[u];
  head[u] = tot;
  to[tot] = v;
}
void BFS(int id, int s) {
  for (int u = 1; u <= n; ++u) vis[u] = 0;
  que.push(s);
  vis[s] = 1;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int e = head[u]; e; e = nxt[e]) {
      int v = to[e];
      if (vis[v]) continue;
      d[id][v] = d[id][u] + 1;
      que.push(v);
      vis[v] = 1;
    }
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d%d%d%d", &n, &m, &a, &b, &c);
    for (int i = 1; i <= m; ++i) scanf("%d", &p[i]);
    sort(p + 1, p + m + 1);
    for (int i = 1; i <= m; ++i) sum[i] = sum[i - 1] + p[i];
    for (int u = 1; u <= n; ++u) head[u] = 0;
    for (int e = 1; e <= tot; ++e) nxt[e] = 0;
    tot = 1;
    for (int i = 1; i <= m; ++i) {
      int u, v;
      scanf("%d%d", &u, &v);
      link(u, v);
      link(v, u);
    }
    long long ans = INF;
    for (int u = 1; u <= n; ++u) d[1][u] = d[2][u] = d[3][u] = 0;
    BFS(1, a);
    BFS(2, b);
    BFS(3, c);
    for (int u = 1; u <= n; ++u) {
      if (d[1][u] + d[2][u] + d[3][u] > m) continue;
      long long tmp =
          2 * sum[d[2][u]] + sum[d[1][u] + d[2][u] + d[3][u]] - sum[d[2][u]];
      ans = min(tmp, ans);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
