#include <bits/stdc++.h>
using namespace std;
vector<long long int> v[200005];
bool vis[200005];
long long int dst[200005][3];
long long int n, m, a, b, c;
void reset() {
  for (long long int i = 0; i < n + 2; i++) {
    v[i].clear();
    vis[i] = false;
    for (long long int j = 0; j < 3; j++) dst[i][j] = 1e18;
  }
}
void djk1(long long int st, long long int ind) {
  priority_queue<pair<long long int, long long int> > q;
  for (long long int i = 0; i < n + 1; i++) {
    vis[i] = false;
    dst[i][ind] = 1e18;
  }
  q.push({0, st});
  while (!q.empty()) {
    pair<long long int, long long int> p = q.top();
    q.pop();
    if (vis[p.second]) {
      continue;
    }
    dst[p.second][ind] = -p.first;
    vis[p.second] = true;
    for (auto j : v[p.second]) {
      if (dst[j][ind] > -p.first + 1) {
        q.push({-(-p.first + 1), j});
      }
    }
  }
}
void solve() {
  cin >> n >> m >> a >> b >> c;
  vector<long long int> val;
  val.resize(m);
  for (long long int i = 0; i < m; i++) {
    cin >> val[i];
  }
  val.push_back(0);
  sort((val).begin(), (val).end());
  for (long long int i = 1; i < m + 1; i++) {
    val[i] += val[i - 1];
  }
  for (long long int i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    v[x].push_back(y), v[y].push_back(x);
  }
  djk1(a, 0);
  djk1(b, 1);
  djk1(c, 2);
  long long int ans = 1e18;
  for (long long int i = 1; i < n + 1; i++) {
    long long int tot = dst[i][0] + dst[i][1] + dst[i][2];
    if (tot <= m) {
      ans = min(ans, val[tot] + val[dst[i][1]]);
    }
  }
  cout << ans << '\n';
  reset();
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tests = 1;
  cin >> tests;
  while (tests--) {
    solve();
  }
}
