#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
struct triple {
  int x, y, z;
};
vector<vector<int> > g;
vector<long long> cost;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t, n, m, a, b, c, u, v;
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    cost.resize(m + 1);
    cost[0] = 0;
    g.clear();
    g.assign(n + 1, vector<int>());
    for (int i = 1; i <= m; ++i) {
      cin >> cost[i];
    }
    sort(cost.begin(), cost.end());
    for (int l = 1; l <= m; ++l) {
      cost[l] += cost[l - 1];
    }
    for (int j = 0; j < m; ++j) {
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    vector<int> vis(n + 1, 0);
    vector<int> disA(n + 1, m + 3);
    vector<int> disB(n + 1, m + 3);
    vector<int> disC(n + 1, m + 3);
    queue<triple> q;
    q.push({b, b, 0});
    q.push({a, a, 0});
    q.push({c, c, 0});
    vis[a] = 1;
    vis[b] = 2;
    vis[c] = 4;
    int p, d;
    int flag = 1;
    while (q.size()) {
      p = q.front().y;
      d = q.front().z;
      v = q.front().x;
      q.pop();
      if (p == a) disA[v] = min(disA[v], d);
      if (p == b) disB[v] = min(disB[v], d);
      if (p == c) disC[v] = min(disC[v], d);
      for (int i = 0; i < g[v].size(); i++) {
        u = g[v][i];
        if (p == a && !(vis[u] & 1)) {
          vis[u]++;
          q.push({u, p, d + 1});
        } else if (p == b && !(vis[u] & 2)) {
          vis[u] += 2;
          q.push({u, p, d + 1});
        } else if (p == c && !(vis[u] & 4)) {
          vis[u] += 4;
          q.push({u, p, d + 1});
        }
      }
    }
    long long ans = 9e18;
    for (int k = 1; k <= n; k++) {
      if (disA[k] + disB[k] + disC[k] > m) continue;
      ans = min(ans, (long long)(cost[disB[k]] * 1LL +
                                 cost[disA[k] + disB[k] + disC[k]] * 1LL));
    }
    cout << ans << "\n";
  }
}
