#include <bits/stdc++.h>
using namespace std;
const long long N = 200500;
const long long mod = 1e9 + 7;
const long double PI = 3.141592654;
vector<long long> xd;
long long ac[N];
vector<long long> adj[N];
long long ad[N], bd[N], cd[N];
bool visa[N], visb[N], visc[N];
void a_bfs(long long a) {
  queue<long long> q_a;
  q_a.push(a);
  visa[a] = true;
  while (!q_a.empty()) {
    long long v = q_a.front();
    q_a.pop();
    for (auto x : adj[v]) {
      if (!visa[x]) {
        visa[x] = true;
        q_a.push(x);
        ad[x] = ad[v] + 1;
      }
    }
  }
}
void b_bfs(long long b) {
  queue<long long> q_b;
  q_b.push(b);
  visb[b] = true;
  while (!q_b.empty()) {
    long long v = q_b.front();
    q_b.pop();
    for (auto x : adj[v]) {
      if (!visb[x]) {
        visb[x] = true;
        q_b.push(x);
        bd[x] = bd[v] + 1;
      }
    }
  }
}
void c_bfs(long long c) {
  queue<long long> q_c;
  q_c.push(c);
  visc[c] = true;
  while (!q_c.empty()) {
    long long v = q_c.front();
    q_c.pop();
    for (auto x : adj[v]) {
      if (!visc[x]) {
        visc[x] = true;
        q_c.push(x);
        cd[x] = cd[v] + 1;
      }
    }
  }
}
long long wea(long long a, long long b, long long m) {
  if (a + b > m) return 1e+18;
  return ac[a] + ac[a + b];
}
int main() {
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    for (long long i = 0; i < n + 5; i++) {
      ad[i] = 0;
      bd[i] = 0;
      cd[i] = 0;
      ac[i] = 0;
      visa[i] = false;
      visb[i] = false;
      visc[i] = false;
      adj[i].clear();
    }
    xd.clear();
    for (long long i = 0; i < m; i++) {
      long long a1;
      cin >> a1;
      xd.push_back(a1);
    }
    sort(xd.begin(), xd.end());
    for (long long i = 0; i < m; i++) {
      ac[i + 1] = ac[i] + xd[i];
    }
    for (long long i = 0; i < m; i++) {
      long long a, b;
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    a_bfs(a);
    b_bfs(b);
    c_bfs(c);
    long long ans = 1e+18;
    for (long long i = 1; i <= n; i++) {
      ans = min(ans, wea(bd[i], ad[i] + cd[i], m));
    }
    cout << ans << endl;
  }
  return 0;
}
