#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T& x) {
  T res = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    res = (res << 3) + (res << 1) + c - '0';
    c = getchar();
  }
  x = res * f;
}
const long long N = 200000 + 10;
int t, n, m, head[N], sumline, dis[N], disn[N][4];
struct line {
  int to, nxt;
} p[N * 10];
void add(int x, int y) {
  p[++sumline] = line{y, head[x]};
  head[x] = sumline;
}
bool vis[N];
queue<int> pls;
void bfs(int x) {
  for (int i = 1; i <= n; i++) dis[i] = 0x3f3f3f3f, vis[i] = 0;
  while (pls.size()) pls.pop();
  pls.push(x);
  dis[x] = 0;
  vis[x] = 1;
  while (pls.size()) {
    int f = pls.front();
    pls.pop();
    for (int i = head[f]; i; i = p[i].nxt) {
      int to = p[i].to;
      if (vis[to]) continue;
      dis[to] = dis[f] + 1;
      vis[to] = 1;
      pls.push(to);
    }
  }
}
long long a, b, c, sum[N], w[N];
int main() {
  read(t);
  while (t--) {
    read(n), read(m), read(a), read(b), read(c);
    for (int i = 1; i <= n; i++) head[i] = 0;
    sumline = 0;
    for (int i = 1; i <= m; i++) {
      read(w[i]);
    }
    sort(w + 1, w + 1 + m);
    for (int i = 1; i <= m; i++) {
      int x, y;
      read(x), read(y);
      add(x, y), add(y, x);
    }
    for (int i = 1; i <= m; i++) sum[i] = sum[i - 1] + w[i];
    bfs(a);
    for (int i = 1; i <= n; i++) disn[i][1] = dis[i];
    bfs(b);
    for (int i = 1; i <= n; i++) disn[i][2] = dis[i];
    bfs(c);
    for (int i = 1; i <= n; i++) disn[i][3] = dis[i];
    long long ans = 0x3f3f3f3f3f3f3f3f;
    for (int i = 1; i <= n; i++) {
      if (disn[i][2] + disn[i][1] + disn[i][3] > m) continue;
      ans =
          min(ans, sum[disn[i][2]] + sum[disn[i][2] + disn[i][1] + disn[i][3]]);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
