#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> inv_help(long long a, long long b) {
  pair<long long, long long> res;
  res.first = 1;
  res.second = 0;
  if (b == 0)
    return res;
  else {
    pair<long long, long long> res1 = inv_help(b, a % b);
    res.first = res1.second;
    res.second = res1.first - (a / b) * res1.second;
    return res;
  }
}
long long inv(long long a, long long b) {
  pair<long long, long long> res = inv_help(a, b);
  long long x = res.first;
  if (x > 0) x = x % b;
  if (x < 0) x = (b - (-x) % b) % b;
  return x;
}
vector<int> l;
int N;
int binsearch(int p, int l_bnd) {
  int i = l_bnd, j = N - 1, k;
  if (l_bnd > N - 1) return -1;
  if (l[N - 1] < p)
    return -1;
  else if (l[i] > p)
    return i;
  else {
    while (i != j) {
      k = (i + j) / 2;
      if (i == j) {
        return i;
      } else if (i == j - 1) {
        if (l[i] == p)
          return i;
        else
          return i + 1;
      } else if (l[k] < p) {
        i = k + 1;
      } else if (l[k] >= p) {
        j = k;
      }
    }
    return i;
  }
}
vector<int> dij(vector<vector<int> > &v, int a) {
  int n = v.size();
  vector<int> vis(n, -1);
  queue<int> q;
  vector<int> level(n, 0);
  vis[a] = 1;
  q.push(a);
  while (q.size() > 0) {
    int t = q.front();
    q.pop();
    int sz = v[t].size();
    for (int i = 0; i < sz; i++) {
      if (vis[v[t][i]] == -1) {
        q.push(v[t][i]);
        vis[v[t][i]] = 1;
        level[v[t][i]] = level[t] + 1;
      }
    }
  }
  return level;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n, m, a, b, c, x, y;
    cin >> n >> m >> a >> b >> c;
    vector<vector<int> > v(n + 1, vector<int>(0));
    vector<long long> M(m + 2, 0);
    long long cost = 0;
    for (int i = 1; i <= m; i++) cin >> M[i];
    sort(M.begin() + 1, M.end() - 1);
    for (int i = 1; i <= m; i++) M[i] = M[i - 1] + M[i];
    for (int i = 0; i < m; i++) {
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    vector<int> p = dij(v, a);
    vector<int> q = dij(v, b);
    vector<int> r = dij(v, c);
    M[m + 1] = 1e15;
    long long mn = 1e15;
    for (int i = 1; i <= n; i++) {
      mn = min(mn, M[q[i]] + M[min(m + 1, q[i] + p[i] + r[i])]);
    }
    cout << mn << "\n";
  }
}
