#include <bits/stdc++.h>
const long long int MOD = 1e9 + 7;
const long long int INF = 1011111111;
const long long int LLINF = 1000111000111000111LL;
const long double EPS = 1e-10;
const long double PI = 3.14159265358979323;
using namespace std;
long long int power(long long int base, long long int exponent) {
  long long int ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base);
    base = (1LL * base * base);
    exponent >>= 1;
  }
  return ans;
}
const long long int N = 2e5 + 5;
vector<long long int> v[N];
vector<long long int> solve(int root, int n) {
  vector<long long int> dis(n + 1, INF);
  vector<bool> visit(n + 1, false);
  dis[root] = 0;
  queue<long long int> q;
  q.push(root);
  while (!q.empty()) {
    long long int u = q.front();
    q.pop();
    for (auto to : v[u]) {
      if (dis[to] == INF) {
        dis[to] = dis[u] + 1;
        q.push(to);
      }
    }
  }
  return dis;
}
void reset(long long int n) {
  for (long long int i = 0; i <= n; i++) v[i].clear();
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m, i, j, k, a, b, c;
    cin >> n >> m >> a >> b >> c;
    vector<long long int> pre(m + 1, 0);
    for (i = 1; i <= m; i++) {
      cin >> pre[i];
    }
    sort(pre.begin(), pre.end());
    for (i = 1; i <= m; i++) pre[i] += pre[i - 1];
    for (i = 0; i < m; i++) {
      long long int x, y;
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    vector<long long int> fa = solve(a, n);
    vector<long long int> fb = solve(b, n);
    vector<long long int> fc = solve(c, n);
    long long int ans = LLINF;
    for (i = 1; i <= n; i++) {
      long long int x = fa[i];
      long long int y = fb[i];
      long long int z = fc[i];
      if (x + y + z <= m) {
        ans = min(ans, pre[x + y + z] + pre[y]);
      }
    }
    cout << ans << '\n';
    reset(n);
  }
  cerr << '\n'
       << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
}
