#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const vector<int> mods = {998244353, 1000000007, 1000000009};
const long long inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class... K>
using umap = unordered_map<K...>;
template <class... K>
using uset = unordered_set<K...>;
long long n, m, a, b, c;
vector<long long> p, pre;
umap<long long, vector<long long> > g;
umap<long long, long long> aw, bw, cw;
void dj(long long x, umap<long long, long long>& w) {
  queue<long long> q;
  q.push(x);
  long long gen = 0;
  while (((int)(q).size())) {
    long long szq = ((int)(q).size());
    for (long long i = (0); i < (szq); ++i) {
      long long node = q.front();
      q.pop();
      if ((w.find(node) != end(w))) continue;
      w[node] = gen;
      for (auto& nx : g[node]) {
        q.push(nx);
      }
    }
    gen++;
  }
}
void solve(int _t) {
  cin >> n >> m >> a >> b >> c;
  a--;
  b--;
  c--;
  g.clear();
  aw.clear();
  bw.clear();
  cw.clear();
  p.assign(m, 0);
  pre.assign(4 * m + 1, 0);
  for (long long i = (0); i < (m); ++i) {
    cin >> p[i];
  }
  sort(begin(p), end(p));
  for (long long i = (0); i < (m); ++i) {
    pre[i + 1] = pre[i] + p[i];
  }
  for (long long i = (m + 1); i < (4 * m + 1); ++i) {
    pre[i] = inf;
  }
  for (long long i = (0); i < (m); ++i) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dj(a, aw);
  dj(b, bw);
  dj(c, cw);
  long long res = inf;
  for (long long i = (0); i < (n); ++i) {
    if (!(aw.find(i) != end(aw)) || !(bw.find(i) != end(bw)) ||
        !(cw.find(i) != end(cw)))
      continue;
    res = min(res, pre[bw[i]] + pre[bw[i] + aw[i] + cw[i]]);
  }
  cout << res << "\n";
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t = 1;
  cin >> t;
  while (t--) solve(t);
  return 0;
}
