#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
void pr_init() {}
vector<vector<long long> > gp;
long long n, m, a, b, c;
vector<vector<long long> > bfs_dis;
void bfs(long long s, long long i) {
  queue<long long> nd;
  nd.push(s);
  bfs_dis[i][s] = 0;
  while ((long long)nd.size() > 0) {
    long long u = nd.front();
    nd.pop();
    for (auto x : gp[u])
      if (bfs_dis[i][x] > bfs_dis[i][u] + 1) {
        bfs_dis[i][x] = bfs_dis[i][u] + 1;
        nd.push(x);
      }
  }
}
void solve() {
  long long t;
  cin >> t;
  for (long long i = 0; i < t; i++) {
    cin >> n >> m >> a >> b >> c;
    vector<long long> we(3 * m + 3, 1e17);
    for (long long j = 1; j < m + 1; j++) cin >> we[j];
    we[0] = 0;
    gp.assign(n + 1, vector<long long>());
    bfs_dis.assign(3, vector<long long>(n + 1, 1e17));
    for (long long j = 0; j < m; j++) {
      long long u, v;
      cin >> u >> v;
      gp[u].push_back(v);
      gp[v].push_back(u);
    }
    sort(we.begin(), we.end());
    for (long long j = 1; j < m + 1; j++) we[j] += we[j - 1];
    bfs(a, 0);
    bfs(b, 1);
    bfs(c, 2);
    long long an = 1e17;
    for (long long i = 1; i < n + 1; i++) {
      long long x1 = bfs_dis[0][i], x2 = bfs_dis[1][i], x3 = bfs_dis[2][i];
      an = min(an, we[x1 + x2 + x3] + we[x2]);
    }
    cout << an << endl;
  }
}
int32_t main() {
  pr_init();
  auto start = high_resolution_clock::now();
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);
  return 0;
}
