#include <bits/stdc++.h>
using namespace std;
template <class T>
struct graph {
  struct edge {
    int to;
    T cost;
    edge(int to, T cost) : to(to), cost(cost) {}
    bool operator<(const edge& r) const { return cost < r.cost; }
  };
  int V;
  vector<vector<edge> > adj;
  graph(int n) { init(n); }
  void init(int size) {
    V = size;
    adj.assign(size, vector<edge>());
  }
  void add_edge(int from, int to, T cost) {
    adj[from].push_back(edge(to, cost));
    adj[to].push_back(edge(from, cost));
  }
  void Dijkstra(int from, T inf, vector<T>& dist) {
    priority_queue<pair<T, int>, vector<pair<T, int> >, greater<pair<T, int> > >
        q;
    dist.assign(V, inf);
    dist[from] = 0;
    q.push(pair<T, int>(0, from));
    while (!q.empty()) {
      pair<T, int> p = q.top();
      q.pop();
      int v = p.second;
      if (p.first > dist[v]) continue;
      for (edge e : adj[v]) {
        if (dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          q.push(pair<T, int>(dist[e.to], e.to));
        }
      }
    }
  }
};
void solve() {
  int n, m, a, b, c;
  cin >> n >> m >> a >> b >> c;
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  graph<int> d(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    d.add_edge(--u, --v, 1);
  }
  vector<int> x, y, z;
  d.Dijkstra(--a, n, x);
  d.Dijkstra(--b, n, y);
  d.Dijkstra(--c, n, z);
  long long ans = 1e18;
  sort(p.begin(), p.end());
  vector<long long> ps(m + 1, 0);
  for (int i = 1; i <= m; i++) ps[i] = ps[i - 1] + p[i - 1];
  for (int i = 0; i < n; i++) {
    int t = x[i] + y[i] + z[i];
    if (t > m) continue;
    long long tmp = ps[y[i]] + ps[t];
    if (ans > tmp) ans = tmp;
  }
  cout << ans << endl;
}
int main(void) {
  int t = 1;
  cin >> t;
  while (t--) solve();
}
