#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T = long long>
using V = vector<T>;
template <class T = long long>
using VV = V<V<T>>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
inline void Yes(bool b = true) { cout << (b ? "Yes" : "No") << '\n'; }
inline void YES(bool b = true) { cout << (b ? "YES" : "NO") << '\n'; }
inline void err(bool b = true) {
  if (b) {
    cout << -1 << '\n';
    exit(0);
  }
}
template <class T>
inline void fin(bool b = true, T e = 0) {
  if (b) {
    cout << e << '\n';
    exit(0);
  }
}
template <class T>
T Roundup_div(T x, T y) {
  return (x + (y - 1)) / y;
}
const long long INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
  T ret = e;
  while (n) {
    if (n & 1) ret *= a;
    a *= a;
    n >>= 1;
  }
  return ret;
}
using Graph = VV<>;
long long n, m, a, b, c, res, pre, sum;
V<> bfs(Graph& G, long long a) {
  V<> dist(n);
  V<bool> vis(n, false);
  queue<int> que;
  dist[a] = 0;
  vis[a] = true;
  que.push(a);
  while (!que.empty()) {
    long long v = que.front();
    que.pop();
    for (long long nv : G[v]) {
      if (vis[nv]) continue;
      dist[nv] = dist[v] + 1;
      que.push(nv);
      vis[nv] = true;
    }
  }
  return dist;
}
void solve() {
  cin >> n >> m >> a >> b >> c;
  a--;
  b--;
  c--;
  V<> p(m);
  for (long long i = (0); i < (m); ++i) cin >> p[i];
  sort((p).begin(), (p).end());
  V<> rui(m + 1);
  for (long long i = (0); i < (m); ++i) rui[i + 1] = rui[i] + p[i];
  Graph G(n);
  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);
  }
  V<> da = bfs(G, a), db = bfs(G, b), dc = bfs(G, c);
  res = INF;
  for (long long i = (0); i < (n); ++i) {
    pre = 0;
    sum = da[i] + db[i] + dc[i];
    if (sum > m) continue;
    long long cnt = 0;
    pre += rui[sum] + rui[db[i]];
    chmin(res, pre);
  }
  cout << res << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) solve();
}
