#include <bits/stdc++.h>
long long bigmod(long long a, long long b) {
  if (b == 0) return 1;
  long long ret = bigmod(a, b / 2);
  return ret * ret % 1000000007 * (b % 2 ? a : 1) % 1000000007;
}
using namespace std;
long long t, n, m, a, b, c;
long long v[200010][5], p[200010];
vector<int> E[200010];
void bfs(long long nd, long long tp) {
  queue<long long> Q;
  v[nd][tp] = 0;
  Q.push(nd);
  while (!Q.empty()) {
    long long x = Q.front();
    Q.pop();
    for (auto i : E[x]) {
      if (v[i][tp] == -1) {
        v[i][tp] = v[x][tp] + 1;
        Q.push(i);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    for (long long i = 1; i <= m; i++) cin >> p[i];
    for (int i = 1; i <= n; i++) E[i].clear();
    for (long long i = 1; i <= m; i++) {
      long long u, v;
      cin >> u >> v;
      E[u].push_back(v);
      E[v].push_back(u);
    }
    for (long long i = 1; i <= n; i++) v[i][1] = v[i][2] = v[i][3] = -1;
    bfs(a, 1);
    bfs(b, 2);
    bfs(c, 3);
    sort(p + 1, p + m + 1);
    for (long long i = 1; i <= m; i++) p[i] += p[i - 1];
    long long ans = 1e16;
    for (long long i = 1; i <= n; i++) {
      long long sum = v[i][1] + v[i][2] + v[i][3];
      if (sum > m) continue;
      ans = min(ans, p[sum] + p[v[i][2]]);
    }
    cout << ans << "\n";
  }
}
