#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    --a;
    --b;
    --c;
    vector<vector<long long>> g(n);
    vector<long long> p(m);
    for (long long i = 0; i < m; ++i) cin >> p[i];
    for (long long i = 0; i < m; ++i) {
      long long u, v;
      cin >> u >> v;
      --u;
      --v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    vector<vector<long long>> dist(3, vector<long long>());
    auto bfs = [&](long long s, vector<long long> &d) {
      d.resize(n, -1);
      queue<long long> q;
      q.push(s);
      d[s] = 0;
      while (q.size()) {
        long long u = q.front();
        q.pop();
        for (auto v : g[u]) {
          if (~d[v]) continue;
          d[v] = d[u] + 1;
          q.push(v);
        }
      }
    };
    bfs(a, dist[0]);
    bfs(b, dist[1]);
    bfs(c, dist[2]);
    p.push_back(0);
    sort(p.begin(), p.end());
    for (long long i = 1; i <= m; ++i) p[i] += p[i - 1];
    long long ans = LLONG_MAX;
    for (long long i = 0; i < n; ++i) {
      long long len = dist[0][i] + dist[1][i] + dist[2][i];
      if (len > m) continue;
      long long cur = p[len] + p[dist[1][i]];
      ans = min(ans, cur);
    }
    cout << ans << '\n';
  }
}
