#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template <class T>
inline bool ckmin(T& a, T b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
inline bool ckmax(T& a, T b) {
  return b > a ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const char nl = '\n';
const int mxN = 2e5 + 10;
const int MOD = 1e9 + 7;
const long long infLL = 1e18;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    a--;
    b--;
    c--;
    vector<ll> p(m);
    vector<vector<int>> adj(n);
    for (int i = (0); i < (m); i++) {
      cin >> p[i];
    }
    sort(p.begin(), p.end());
    for (int i = (1); i < (m); i++) {
      p[i] += p[i - 1];
    }
    vector<int> da, db, dc;
    for (int i = (0); i < (m); i++) {
      int e1, e2;
      cin >> e1 >> e2;
      e1--;
      e2--;
      adj[e1].push_back(e2);
      adj[e2].push_back(e1);
    }
    auto BFS = [&](int x) {
      vector<int> dist;
      dist.resize(n);
      vector<int> vis;
      vis.resize(n);
      dist[x] = 0;
      vis[x] = 1;
      queue<int> q;
      q.push(x);
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto& u : adj[v])
          if (!vis[u]) {
            q.push(u);
            dist[u] = dist[v] + 1;
            vis[u] = 1;
          }
      }
      return dist;
    };
    da = BFS(a), db = BFS(b), dc = BFS(c);
    ll res = infLL;
    for (int i = (0); i < (n); i++) {
      int x = db[i];
      int v = da[i] + dc[i];
      if (v + x - 1 >= m) continue;
      if (x - 1 >= m) continue;
      ll dist = (x == 0 ? 0 : p[x - 1]) * 2 +
                ((v + x == 0 ? 0 : p[v + x - 1]) - (x == 0 ? 0 : p[x - 1]));
      ckmin(res, dist);
    }
    cout << res << nl;
  }
  return 0;
}
