#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[200100];
long long x, y, z;
long long pr[200100];
long long dis[4][200100];
bool vis[200100];
vector<long long> g[200100];
void bfs(int x, int ld) {
  queue<long long> q;
  q.push(x);
  vis[x] = 1;
  dis[ld][x] = 0;
  while (!q.empty()) {
    long long v = q.front();
    q.pop();
    for (int i = 0; i < g[v].size(); i++) {
      long long to = g[v][i];
      if (!vis[to]) {
        vis[to] = 1;
        q.push(to);
        dis[ld][to] = dis[ld][v] + 1;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    cin >> x >> y >> z;
    for (int i = 0; i <= n; i++) {
      g[i].clear();
      dis[0][i] = 1e17;
      dis[1][i] = 1e17;
      dis[2][i] = 1e17;
    }
    for (int i = 0; i < m; i++) {
      cin >> a[i];
    }
    sort(a, a + m);
    for (int i = 1; i <= m; i++) {
      pr[i] = pr[i - 1];
      pr[i] += a[i - 1];
    }
    for (int i = 0; i < m; i++) {
      long long aa, bb;
      cin >> aa >> bb;
      g[aa].push_back(bb);
      g[bb].push_back(aa);
    }
    for (int i = 0; i <= n; i++) vis[i] = 0;
    bfs(x, 0);
    for (int i = 0; i <= n; i++) vis[i] = 0;
    bfs(y, 1);
    for (int i = 0; i <= n; i++) vis[i] = 0;
    bfs(z, 2);
    long long sol = 1e17;
    for (int i = 1; i <= n; i++) {
      long long d1 = dis[0][i];
      long long d2 = dis[2][i];
      long long dd = dis[1][i];
      long long ss = 2 * pr[dd];
      long long w = d1 + d2 + dd;
      ss += (pr[w] - pr[dd]);
      if (w > m) continue;
      sol = min(sol, ss);
    }
    cout << sol << endl;
  }
  return 0;
}
