#include <bits/stdc++.h>
using namespace std;
vector<long long int> g[200001];
bool v1[200001];
bool v2[200001];
bool v3[200001];
long long int d1[200001];
long long int d2[200001];
long long int d3[200001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    long long int w[m + 1];
    for (long long int i = 1; i <= n; i++) {
      v1[i] = false;
      v2[i] = false;
      v3[i] = false;
      d1[i] = 0;
      d2[i] = 0;
      d3[i] = 0;
      g[i].clear();
    }
    w[0] = 0;
    for (long long int i = 1; i <= m; i++) cin >> w[i];
    sort(w, w + m + 1);
    for (long long int i = 1; i <= m; i++) {
      long long int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
      w[i] += w[i - 1];
    }
    queue<long long int> q;
    q.push(a);
    v1[a] = true;
    while (!q.empty()) {
      long long int f = q.front();
      q.pop();
      for (long long int i = 0; i < g[f].size(); i++) {
        if (!v1[g[f][i]]) {
          d1[g[f][i]] = d1[f] + 1;
          v1[g[f][i]] = true;
          q.push(g[f][i]);
        }
      }
    }
    q.push(b);
    v2[b] = true;
    while (!q.empty()) {
      long long int f = q.front();
      q.pop();
      for (long long int i = 0; i < g[f].size(); i++) {
        if (!v2[g[f][i]]) {
          d2[g[f][i]] = d2[f] + 1;
          v2[g[f][i]] = true;
          q.push(g[f][i]);
        }
      }
    }
    q.push(c);
    v3[c] = true;
    while (!q.empty()) {
      long long int f = q.front();
      q.pop();
      for (long long int i = 0; i < g[f].size(); i++) {
        if (!v3[g[f][i]]) {
          d3[g[f][i]] = d3[f] + 1;
          v3[g[f][i]] = true;
          q.push(g[f][i]);
        }
      }
    }
    long long int sum = LLONG_MAX;
    for (long long int i = 1; i <= n; i++) {
      long long int temp = LLONG_MAX;
      if (d1[i] + d2[i] + d3[i] <= m)
        temp = w[d2[i]] + w[d1[i] + d2[i] + d3[i]];
      sum = min(sum, temp);
    }
    cout << sum << "\n";
  }
}
