#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[200005];
vector<int> visited(200005, 0);
vector<long long int> dist(200005);
long long int n, m;
void bfs(long long int s) {
  queue<long long int> qn;
  qn.push(s);
  visited[s] = 1;
  dist[s] = 0;
  while (!qn.empty()) {
    long long int v = qn.front();
    qn.pop();
    for (long long int j = 0; j < adj[v].size(); j++) {
      if (visited[adj[v][j]] == 0) {
        qn.push(adj[v][j]);
        visited[adj[v][j]] = 1;
        dist[adj[v][j]] = dist[v] + 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int w;
  cin >> w;
  while (w--) {
    long long int a, b, c;
    cin >> n >> m >> a >> b >> c;
    for (long long int i = 1; i <= n; i++) {
      adj[i].clear();
      visited[i] = 0;
    }
    vector<long long int> p(m + 1);
    for (long long int i = 1; i <= m; i++) {
      cin >> p[i];
    }
    for (long long int i = 1; i <= m; i++) {
      long long int x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    sort((p).begin(), (p).end());
    for (long long int i = 1; i <= m; i++) {
      p[i] += p[i - 1];
    }
    vector<long long int> d1(n + 1), d2(n + 1), d3(n + 1);
    bfs(a);
    for (long long int i = 1; i <= n; i++) {
      d1[i] = dist[i];
      visited[i] = 0;
    }
    bfs(b);
    for (long long int i = 1; i <= n; i++) {
      d2[i] = dist[i];
      visited[i] = 0;
    }
    bfs(c);
    for (long long int i = 1; i <= n; i++) {
      d3[i] = dist[i];
      visited[i] = 0;
    }
    long long int ans = 1e18;
    for (long long int i = 1; i <= n; i++) {
      long long int edg = d1[i] + d2[i] + d3[i];
      if (edg > m) continue;
      ans = min(ans, p[edg] + p[d2[i]]);
    }
    cout << ans << '\n';
  }
  return 0;
}
