#include <bits/stdc++.h>
using namespace std;
vector<int> dis(vector<vector<int> >& v, int x) {
  int n = v.size();
  vector<int> visited(n, -1);
  queue<int> q;
  q.push(x);
  visited[x] = 0;
  while (q.size()) {
    int t = q.front();
    int val = visited[t];
    q.pop();
    for (int i = 0; i < v[t].size(); i++) {
      if (visited[v[t][i]] == -1) {
        visited[v[t][i]] = val + 1;
        q.push(v[t][i]);
      }
    }
  }
  return visited;
}
void solve() {
  int n, m, a, b, c;
  cin >> n >> m >> a >> b >> c;
  a--;
  b--;
  c--;
  vector<vector<int> > v(n);
  vector<long long> p(m + 1);
  for (int i = 0; i < m; i++) {
    cin >> p[i + 1];
  }
  sort(p.begin(), p.end());
  for (int i = 1; i < p.size(); i++) {
    p[i] += p[i - 1];
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  vector<int> aa = dis(v, a);
  vector<int> bb = dis(v, b);
  vector<int> cc = dis(v, c);
  long long R = 1e18;
  for (int i = 0; i < n; i++) {
    int a1 = aa[i];
    int b1 = bb[i];
    int c1 = cc[i];
    if (a1 + b1 + c1 < p.size()) {
      long long r = p[b1] + p[a1 + b1 + c1];
      R = min(R, r);
    }
  }
  cout << R << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
