#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long arr[maxn], n, m, a, b, c, sum[maxn];
vector<long long> vec[maxn];
queue<long long> que;
long long disa[maxn], disb[maxn], disc[maxn];
void bfs(long long s, long long dis[]) {
  que.push(s);
  fill(dis, dis + n + 1, -1);
  dis[s] = 0;
  while (!que.empty()) {
    long long x = que.front();
    que.pop();
    for (auto p : vec[x]) {
      if (dis[p] == -1) {
        dis[p] = dis[x] + 1;
        que.push(p);
      }
    }
  }
}
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    for (long long i = 1; i <= n; i++) {
      vec[i].clear();
    }
    for (long long i = 0; i < m; i++) {
      cin >> arr[i];
    }
    sort(arr, arr + m);
    sum[0] = arr[0];
    for (long long i = 1; i < m; i++) {
      sum[i] = sum[i - 1] + arr[i];
    }
    for (long long i = 0; i < m; i++) {
      long long u, v;
      cin >> u >> v;
      vec[u].push_back(v);
      vec[v].push_back(u);
    }
    bfs(a, disa);
    bfs(b, disb);
    bfs(c, disc);
    long long ans = LLONG_MAX;
    for (long long i = 1; i <= n; i++) {
      long long len1 = disa[i];
      long long len2 = disc[i];
      long long len3 = disb[i];
      if (len1 + len2 + len3 <= m) {
        ans = min(ans, sum[len3 - 1] + sum[len3 + len1 + len2 - 1]);
      }
    }
    cout << ans << endl;
  }
}
