#include <bits/stdc++.h>
using namespace std;
long long p = 1e9 + 7;
int max(int a, int b) { return a < b ? b : a; }
int min(int a, int b) { return a < b ? a : b; }
const int mx = 2e5 + 9;
int inf = 1e9;
long long Inf = 1e18;
vector<int> w[mx];
multiset<pair<int, int>> M;
void solve(int t) {
  int n, m, a, b, c;
  cin >> n >> m >> a >> b >> c;
  long long p[m];
  M.clear();
  for (int i = 0; i < m; i++) cin >> p[i];
  long long s[m];
  sort(p, p + m);
  s[0] = 0;
  for (int i = 0; i <= n; i++) {
    w[i].clear();
  }
  for (int i = 1; i <= m; i++) {
    s[i] = s[i - 1] + p[i - 1];
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    w[u].push_back(v);
    w[v].push_back(u);
  }
  long long mn = Inf;
  int da[n + 2];
  int db[n + 2];
  int dc[n + 2];
  int pa[n + 2];
  int pb[n + 2];
  int pc[n + 2];
  for (int i = 0; i < n + 2; i++) {
    pa[i] = 0;
    pb[i] = 0;
    pc[i] = 0;
    da[i] = inf;
    da[i] = inf;
    da[i] = inf;
  }
  pa[a] = a;
  da[a] = 0;
  queue<int> q;
  q.push(a);
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    for (auto u : w[s]) {
      if (pa[u]) continue;
      pa[u] = s;
      da[u] = da[s] + 1;
      q.push(u);
    }
  }
  pb[b] = b;
  db[b] = 0;
  q.push(b);
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    for (auto u : w[s]) {
      if (pb[u]) continue;
      pb[u] = s;
      db[u] = db[s] + 1;
      q.push(u);
    }
  }
  pc[c] = c;
  dc[c] = 0;
  q.push(c);
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    for (auto u : w[s]) {
      if (pc[u]) continue;
      pc[u] = s;
      dc[u] = dc[s] + 1;
      q.push(u);
    }
  }
  int crt = 0;
  for (int mid = 1; mid <= n; mid++) {
    int x = da[mid];
    int y = db[mid];
    int z = dc[mid];
    if (x + y + z <= m) {
      if (mn > s[y] + s[x + y + z]) {
        mn = s[y] + s[x + y + z];
        crt = mid;
      }
    }
  }
  cout << mn << endl;
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    solve(t);
  }
}
