#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, c, head[200005], ver[2 * 200005], Next[2 * 200005],
    dist[3][200005], tot = 0;
long long edge[200005];
void add(int x, int y) {
  ver[++tot] = y;
  Next[tot] = head[x];
  head[x] = tot;
}
struct node {
  int num;
  int cnt;
};
void bfs(int num, int x) {
  bool vis[200005] = {0};
  queue<node> q;
  node start = {num, 0};
  q.push(start);
  while (q.size()) {
    node pre = q.front();
    q.pop();
    if (vis[pre.num]) continue;
    vis[pre.num] = 1;
    dist[x][pre.num] = pre.cnt;
    int i;
    for (i = head[pre.num]; i; i = Next[i]) {
      int y = ver[i];
      if (vis[y]) continue;
      node nxt;
      nxt.cnt = pre.cnt + 1;
      nxt.num = y;
      q.push(nxt);
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    tot = 0;
    scanf("%d%d%d%d%d", &n, &m, &a, &b, &c);
    long long i;
    for (i = 1; i <= max((long long)n,
                         min((long long)200002, (long long)n * (n - 1) / 2));
         i++) {
      dist[0][i] = dist[1][i] = dist[2][i] = head[i] = ver[i] = Next[i] =
          edge[i] = 0;
    }
    for (i = 1; i <= m; i++) scanf("%lld", &edge[i]);
    sort(edge + 1, edge + m + 1);
    edge[0] = 0;
    for (i = 1; i <= m; i++) edge[i] += edge[i - 1];
    for (i = 1; i <= m; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      add(x, y);
      add(y, x);
    }
    bfs(a, 0);
    bfs(b, 1);
    bfs(c, 2);
    long long ans = ~0ull >> 2;
    for (i = 1; i <= n; i++) {
      if (dist[0][i] + dist[1][i] + dist[2][i] > m) continue;
      long long temp =
          edge[dist[0][i] + dist[1][i] + dist[2][i]] + edge[dist[1][i]];
      ans = min(ans, temp);
    }
    cout << ans << endl;
  }
  return 0;
}
