#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-ffloat-store")
#pragma GCC optimize("-fno-defer-pop")
long long int power(long long int a, long long int b, long long int m) {
  if (b == 0) return 1;
  if (b == 1) return a % m;
  long long int t = power(a, b / 2, m) % m;
  t = (t * t) % m;
  if (b & 1) t = ((t % m) * (a % m)) % m;
  return t;
}
long long int modInverse(long long int a, long long int m) {
  return power(a, m - 2, m);
}
long long int n, m, dt[3][3000005];
vector<long long int> vc[3000005];
void bfs(long long int st, long long int flg) {
  queue<long long int> qe;
  long long int i, j;
  for (i = 1; i <= n; i++) {
    dt[flg][i] = 1e18;
  }
  dt[flg][st] = 0;
  qe.push(st);
  while (qe.size() > 0) {
    i = qe.front();
    qe.pop();
    for (auto it : vc[i]) {
      if (dt[flg][it] == 1e18) {
        dt[flg][it] = dt[flg][i] + 1;
        qe.push(it);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int i, j, k, l, a, b, c;
    cin >> n >> m >> a >> b >> c;
    vector<long long int> ar;
    ar.push_back(0);
    for (i = 1; i <= m; i++) {
      cin >> j;
      ar.push_back(j);
    }
    for (i = 1; i <= m; i++) {
      cin >> k >> l;
      vc[k].push_back(l);
      vc[l].push_back(k);
    }
    sort(ar.begin(), ar.end());
    bfs(a, 0);
    bfs(b, 1);
    bfs(c, 2);
    for (i = 1; i <= m; i++) {
      ar[i] += ar[i - 1];
    }
    long long int an = 1e18;
    for (i = 1; i <= n; i++) {
      if (dt[0][i] + dt[1][i] + dt[2][i] <= m) {
        an = min(an, ar[dt[1][i]] + ar[dt[0][i] + dt[1][i] + dt[2][i]]);
      }
      vc[i].clear();
    }
    cout << an << "\n";
  }
  return 0;
}
