#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
void ingraph(vector<long long> graph[], long long m) {
  long long x, y;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    x--, y--;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long modmulti(long long a, long long b) {
  return ((a % mod) * 1ll * (b % mod)) % mod;
}
long long modadd(long long a, long long b) {
  long long asdfgh = ((a % mod) + (b % mod) + mod + mod) % mod;
  asdfgh = (asdfgh + mod) % mod;
  return asdfgh;
}
long long modpower(long long a, long long n) {
  if (n == 0) return 1;
  if (n == 1) return a % mod;
  long long b = modpower(a, n / 2);
  b = modmulti(b, b);
  if (n % 2 == 0) return b;
  return modmulti(a, b);
}
long long modinv(long long a) { return modpower(a, mod - 2); }
long long visited[200005];
long long *bfs(vector<long long> adj[], long long u, long long *a) {
  visited[u] = 1;
  queue<long long> q;
  q.push(u);
  a[u] = 0;
  while (!q.empty()) {
    long long x = q.front();
    for (auto it : adj[x]) {
      if (visited[it] == 0) {
        visited[it] = 1;
        q.push(it);
        a[it] = a[x] + 1;
      }
    }
    q.pop();
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m, a1, b1, c1;
    cin >> n >> m >> a1 >> b1 >> c1;
    a1--;
    b1--;
    c1--;
    long long cost[m];
    for (long long i = 0; i < m; i++) cin >> cost[i];
    sort(cost, cost + m);
    long long sum[m + 5];
    sum[0] = 0;
    for (long long i = 0; i < m; i++) sum[i + 1] = sum[i] + cost[i];
    vector<long long> adj[n];
    ingraph(adj, m);
    long long *a, *b, *c;
    a = (long long *)malloc(n * sizeof(long long));
    b = (long long *)malloc(n * sizeof(long long));
    c = (long long *)malloc(n * sizeof(long long));
    for (long long i = 0; i < n; i++) visited[i] = 0;
    a = bfs(adj, a1, a);
    for (long long i = 0; i < n; i++) visited[i] = 0;
    b = bfs(adj, b1, b);
    for (long long i = 0; i < n; i++) visited[i] = 0;
    c = bfs(adj, c1, c);
    long long ans = 1e18;
    for (long long i = 0; i < n; i++) {
      long long u = b[i];
      long long v = a[i] + b[i] + c[i];
      long long tmp;
      if (v > m)
        tmp = 1e18;
      else
        tmp = sum[u] + sum[v];
      ans = min(ans, tmp);
    }
    cout << ans << '\n';
  }
  return 0;
}
