#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
long long pr[N];
int sv[N][3];
vector<int> ok[N];
void bfs(int node, int t) {
  queue<int> let;
  let.push(node);
  while (!let.empty()) {
    int v = let.front();
    let.pop();
    for (int i = 0; i < ok[v].size(); i++) {
      int u = ok[v][i];
      if (u == node) continue;
      if (!sv[u][t]) {
        sv[u][t] = sv[v][t] + 1;
        let.push(u);
      }
    }
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m, a, b, c;
    scanf("%d%d%d%d%d", &n, &m, &a, &b, &c);
    vector<int> s(m + 1);
    for (int i = 1; i <= m; i++) scanf("%d", &s[i]);
    sort(s.begin(), s.end());
    for (int i = 1; i <= m; i++) pr[i] = pr[i - 1] + s[i];
    for (int i = 0; i < m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      ok[u].push_back(v);
      ok[v].push_back(u);
    }
    bfs(a, 0);
    bfs(b, 1);
    bfs(c, 2);
    long long ans = 1e18;
    for (int i = 1; i <= n; i++) {
      int path = sv[i][0] + sv[i][1] + sv[i][2];
      if (path > m) continue;
      ans = min(ans, pr[sv[i][1]] + pr[path]);
    }
    for (int i = 1; i <= n; i++) {
      sv[i][0] = sv[i][1] = sv[i][2] = pr[i] = 0;
      ok[i].clear();
    }
    printf("%lld\n", ans);
  }
  return 0;
}
