#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
int T, n, m;
vector<vector<int>> G;
vector<int> bfs(int x) {
  queue<int> q;
  vector<int> ret(n + 1, n + 1), vis(n + 1);
  q.push(x);
  vis[x] = 1;
  ret[x] = 0;
  while (!q.empty()) {
    int hd = q.front();
    q.pop();
    for (auto v : G[hd]) {
      ret[v] = min(ret[v], ret[hd] + 1);
      if (!vis[v]) {
        q.push(v);
        vis[v] = 1;
      }
    }
  }
  return ret;
}
void Main() {
  int a, b, c;
  cin >> n >> m >> a >> b >> c;
  G = vector<vector<int>>(n + 1);
  vector<long long> p(m + 1), sum(m + 1);
  for (int i = 1; i <= m; ++i) {
    cin >> p[i];
  }
  sort(p.begin() + 1, p.end());
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
    sum[i] = sum[i - 1] + p[i];
  }
  auto da = bfs(a);
  auto db = bfs(b);
  auto dc = bfs(c);
  long long ans = 1e18;
  for (int i = 1; i <= n; ++i) {
    int cnt1 = db[i];
    int cnt2 = da[i] + dc[i];
    if (cnt1 + cnt2 <= m) {
      ans = min(ans, sum[cnt1] + sum[cnt1 + cnt2]);
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  while (T--) Main();
  return 0;
}
