#include <bits/stdc++.h>
using namespace std;
void bfs(int a, vector<int> &dist, vector<vector<int> > edges) {
  queue<int> q;
  q.push(a);
  vector<bool> visited(dist.size(), false);
  visited[a] = true;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto it = edges[u].begin(); it != edges[u].end(); it++) {
      if (!visited[*it]) {
        q.push(*it);
        visited[*it] = true;
        dist[*it] = dist[u] + 1;
      }
    }
  }
}
int main() {
  int t, n, m, a, b, c, x, y;
  cin >> t;
  for (int _ = 1; _ <= t; _++) {
    cin >> n >> m >> a >> b >> c;
    a--;
    b--;
    c--;
    vector<long long> prices(m, 0);
    for (int i = 0; i < m; i++) cin >> prices[i];
    sort(prices.begin(), prices.end());
    std::vector<long long> prefix(m + 1, 0);
    for (int i = 0; i < m; i++) prefix[i + 1] = prefix[i] + prices[i];
    vector<vector<int> > edges(n, vector<int>());
    for (int i = 0; i < m; i++) {
      cin >> x >> y;
      x--;
      y--;
      edges[x].push_back(y);
      edges[y].push_back(x);
    }
    vector<int> da(n, 1e9);
    vector<int> db(n, 1e9);
    vector<int> dc(n, 1e9);
    da[a] = 0;
    db[b] = 0;
    dc[c] = 0;
    bfs(a, da, edges);
    bfs(b, db, edges);
    bfs(c, dc, edges);
    long long ans = 1e18;
    for (int i = 0; i < n; i++) {
      if (da[i] + db[i] + dc[i] <= m)
        ans = min(ans, prefix[db[i]] + prefix[da[i] + db[i] + dc[i]]);
    }
    cout << ans << endl;
  }
  return 0;
}
