#include <bits/stdc++.h>
using namespace std;
int static fast = []() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  return 0;
}();
int main() {
  int t, n, m, a, b, c, u, v;
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    vector<long long> price(m, 0);
    for (auto& val : price) cin >> val;
    sort(price.begin(), price.end());
    vector<long long> acc(m + 1, 0);
    for (int i = 0; i < m; i++) {
      acc[i + 1] = acc[i] + price[i];
    }
    unordered_map<int, vector<int>> e;
    for (int i = 0; i < m; i++) {
      cin >> u >> v;
      e[u - 1].push_back(v - 1);
      e[v - 1].push_back(u - 1);
    }
    auto bfs = [&](int init) -> vector<int> {
      vector<int> dq = {init};
      vector<int> dis(n, INT_MAX);
      dis[init] = 0;
      int step = 1;
      while (!dq.empty()) {
        vector<int> new_dq;
        for (int node : dq) {
          for (int neibor : e[node]) {
            if (dis[neibor] == INT_MAX) {
              dis[neibor] = step;
              new_dq.push_back(neibor);
            }
          }
        }
        dq.swap(new_dq);
        step += 1;
      }
      return dis;
    };
    auto dis_a = bfs(a - 1);
    auto dis_b = bfs(b - 1);
    auto dis_c = bfs(c - 1);
    long long ans = 1e15;
    for (int i = 0; i < n; i++) {
      long long ac = dis_a[i] + dis_c[i];
      long long tmp = acc[dis_b[i]] * 2;
      if (dis_b[i] + ac > m) {
        continue;
      }
      tmp += acc[dis_b[i] + ac] - acc[dis_b[i]];
      ans = min(ans, tmp);
    }
    cout << ans << "\n";
  }
  return 0;
}
