#include <bits/stdc++.h>
using namespace std;
long long const MOD = 1e9 + 7;
vector<long long> val[200007];
void dfs(long long ind, vector<long long>& d) {
  d[ind] = 0;
  queue<int> q;
  q.push(ind);
  while (q.size() > 0) {
    long long tt = q.front();
    q.pop();
    for (auto it : val[tt]) {
      if (d[it] == -1) {
        d[it] = d[tt] + 1;
        q.push(it);
      }
    }
  }
}
void solve() {
  long long n, m, a, b, c, i, u, v;
  cin >> n >> m >> a >> b >> c;
  vector<long long> disA(n + 1, -1);
  vector<long long> disB(n + 1, -1);
  vector<long long> disC(n + 1, -1);
  vector<long long> vl(m);
  for (i = 0; i < m; i++) cin >> vl[i];
  sort(vl.begin(), vl.end());
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    val[u].push_back(v);
    val[v].push_back(u);
  }
  dfs(a, disA);
  dfs(b, disB);
  dfs(c, disC);
  vector<long long> pre(m + 1);
  for (i = 0; i < m; i++) {
    pre[i + 1] = pre[i] + vl[i];
  }
  long long ans = LLONG_MAX;
  for (i = 1; i <= n; i++) {
    if (disA[i] + disB[i] + disC[i] <= m) {
      ans = min(ans, pre[disA[i] + disB[i] + disC[i]] + pre[disB[i]]);
    }
    val[i].clear();
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
