#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const long long mod = 1e9 + 7;
template <typename T>
inline T gcd(T a, T b) {
  return !b ? a : gcd(b, a % b);
}
template <typename T>
inline T q_pow(T a, T x) {
  T ans = 1, tmp = a;
  while (x) {
    if (x & 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    x >>= 1;
  }
  return ans;
}
template <typename T>
inline void re(T &N) {
  int f = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') f = -1;
  N = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') N = N * 10 + c - '0';
  N *= f;
}
int m, n, t = 1, st, en, a, b, c;
int da[N], db[N], dc[N];
long long dis[N], ans;
struct edge {
  int to, nxt;
  edge(int to = 0, int nxt = 0) : to(to), nxt(nxt) {}
} e[N << 1];
int head[N];
inline void add(int x, int y) {
  e[++t] = edge(y, head[x]);
  head[x] = t;
  e[++t] = edge(x, head[y]);
  head[y] = t;
}
void bfs(int *d, int a) {
  queue<int> q;
  fill(d + 1, d + n + 1, -1);
  d[a] = 0;
  q.push(a);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = head[x]; i; i = e[i].nxt) {
      int to = e[i].to;
      if (d[to] >= 0) continue;
      d[to] = d[x] + 1;
      q.push(to);
    }
  }
}
int main() {
  int cas;
  re(cas);
  while (cas--) {
    re(n);
    re(m);
    re(a);
    re(b);
    re(c);
    t = 1;
    for (int i = 1; i <= n; i++) head[i] = 0;
    for (int i = 1; i <= m; i++) re(dis[i]);
    sort(dis + 1, dis + m + 1);
    for (int i = 1; i <= m; i++) dis[i] += dis[i - 1];
    for (int i = 1; i <= m; i++) {
      int x, y;
      re(x);
      re(y);
      add(x, y);
    }
    bfs(da, a);
    bfs(db, b);
    bfs(dc, c);
    long long ans = 1e18;
    for (int i = 1; i <= n; i++)
      if (da[i] + db[i] + dc[i] <= m) {
        ans = min(ans, dis[db[i]] + dis[da[i] + db[i] + dc[i]]);
      }
    printf("%lld\n", ans);
  }
}
