#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
const int N = 2e5 + 1;
int n, m, x[3];
vector<int> a[N], dis[3];
long long p[N];
void bfs(int s, int cur) {
  dis[cur].assign(n + 1, -1);
  ;
  queue<int> Q;
  Q.push(s);
  dis[cur][s] = 0;
  while (Q.size()) {
    int u = Q.front();
    Q.pop();
    for (int v : a[u]) {
      if (dis[cur][v] == -1) {
        dis[cur][v] = dis[cur][u] + 1;
        Q.push(v);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> n >> m >> x[0] >> x[1] >> x[2];
    for (int i = 1; i <= n; i++) a[i].clear();
    for (int i = 0; i < 3; i++) dis[i].clear();
    for (int i = 1; i <= m; i++) cin >> p[i];
    sort(p + 1, p + 1 + m);
    for (int i = 1; i <= m; i++) p[i] += p[i - 1];
    for (int i = 1; i <= m; i++) {
      int u, v;
      cin >> u >> v;
      a[u].push_back(v);
      a[v].push_back(u);
    }
    for (int i = 0; i < 3; i++) bfs(x[i], i);
    long long res = INF;
    for (int i = 1; i <= n; i++) {
      int k = 0;
      for (int j = 0; j < 3; j++) k += dis[j][i];
      if (k > m) continue;
      res = min(res, p[k] + p[dis[1][i]]);
    }
    cout << res << '\n';
  }
  return 0;
}
