#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 10;
const double inf = 1000;
const long long mod = 1000;
long long _pow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
long long n, m, a, b, c;
vector<long long> g[maxn];
long long p[maxn], sum[maxn], dist1[maxn], dist2[maxn], dist3[maxn], vis[maxn];
void bfs(long long x, long long dist[]) {
  for (long long i = 1; i <= n; i++) {
    vis[i] = 0;
  }
  vis[x] = 1;
  dist[x] = 0;
  queue<long long> q;
  q.push(x);
  while (!q.empty()) {
    long long now = q.front();
    q.pop();
    for (auto v : g[now]) {
      if (!vis[v]) {
        vis[v] = 1;
        dist[v] = dist[now] + 1;
        q.push(v);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    for (long long i = 1; i <= m; i++) {
      cin >> p[i];
    }
    sort(p + 1, p + m + 1);
    for (long long i = 1; i <= m; i++) {
      sum[i] = sum[i - 1] + p[i];
    }
    for (long long i = 1; i <= m; i++) {
      long long u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    bfs(a, dist1);
    bfs(b, dist2);
    bfs(c, dist3);
    long long ans = 2e14;
    for (long long i = 1; i <= n; i++) {
      if (dist1[i] + dist2[i] + dist3[i] > m) continue;
      ans = min(ans, sum[dist1[i] + dist2[i] + dist3[i]] + sum[dist2[i]]);
    }
    cout << ans << endl;
    for (long long i = 1; i <= n; i++) {
      g[i].clear();
    }
  }
  return 0;
}
