#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
int powm(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
const int maxn = 2 * 1e5;
vector<vector<int>> adj;
vector<int> bfs(int s) {
  queue<int> q;
  int n = adj.size();
  vector<int> dis(n + 2, 1000000000);
  dis[s] = 0;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : adj[u]) {
      if (dis[v] > dis[u] + 1) {
        dis[v] = min(dis[v], dis[u] + 1);
        q.push(v);
      }
    }
  }
  return move(dis);
}
void solve() {
  int n, m, a, b, c;
  cin >> n >> m >> a >> b >> c;
  adj.resize(n + 2);
  for (int i = 1; i <= n; i++) adj[i].clear();
  int p[m + 2];
  for (int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  sort(p + 1, p + 1 + m);
  vector<long long> pre(m + 2, 0);
  pre[1] = p[1];
  for (int i = 2; i <= m; i++) {
    pre[i] += pre[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 cur = da[i] + db[i] + dc[i];
    if (cur > m) continue;
    int cc = ans;
    ans = min(ans, pre[cur] + pre[db[i]]);
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
