#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int inf = 1e9 + 7;
const long long INF = 1e18;
int n, m, a, b, c;
long long p[maxn], tag[maxn], cap[2][maxn];
int head[maxn], tot = 0, vis[maxn];
struct node {
  int v, nxt;
} g[maxn << 1];
void add(int u, int v) {
  g[tot] = {v, head[u]};
  head[u] = tot++;
}
void bfs(int op) {
  int st = a;
  if (op == 1) st = c;
  for (int i = 0; i <= n; i++) vis[i] = 0, cap[op][i] = inf;
  queue<int> Q;
  Q.push(st);
  vis[st] = 1;
  cap[op][st] = 0;
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    for (int i = head[x]; ~i; i = g[i].nxt) {
      int v = g[i].v;
      if (!vis[v] && cap[op][v] > cap[op][x] + 1) {
        Q.push(v);
        vis[v] = 1;
        cap[op][v] = cap[op][x] + 1;
      }
    }
  }
}
long long check() {
  long long ans = INF;
  for (int i = 1; i <= m; i++) p[i] += p[i - 1];
  for (int i = 1; i <= n; i++) tag[i] = inf, vis[i] = 0;
  queue<int> Q;
  Q.push(b);
  tag[b] = 0;
  vis[b] = 1;
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    if (tag[x] + cap[0][x] + cap[1][x] <= m) {
      long long res = p[tag[x]] + p[tag[x] + cap[0][x] + cap[1][x]];
      ans = min(ans, res);
    }
    for (int i = head[x]; ~i; i = g[i].nxt) {
      int v = g[i].v;
      if (tag[v] > tag[x] + 1 && !vis[v]) {
        tag[v] = tag[x] + 1;
        Q.push(v);
        vis[v] = 1;
      }
    }
  }
  return ans;
}
void rua() {
  scanf("%d%d%d%d%d", &n, &m, &a, &b, &c);
  for (int i = 1; i <= m; i++) scanf("%lld", &p[i]);
  sort(p + 1, p + 1 + m);
  tot = 0;
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  int tt = 0;
  bfs(tt);
  bfs(++tt);
  printf("%lld\n", check());
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) rua();
  return 0;
}
