#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 9;
const long long oo = 1e16;
long long dist[4][N], node[4], n, m, p[N];
vector<long long> a[N];
void bfs(long long id) {
  queue<long long> q;
  long long x = node[id];
  dist[id][x] = 0;
  q.push(x);
  while (!q.empty()) {
    long long x = q.front();
    q.pop();
    for (long long xnew : a[x])
      if (dist[id][xnew] == 0 && xnew != node[id]) {
        dist[id][xnew] = dist[id][x] + 1;
        q.push(xnew);
      }
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long test;
  cin >> test;
  while (test--) {
    cin >> n >> m >> node[1] >> node[2] >> node[3];
    for (long long i = 1; i <= n; i++) {
      a[i].clear();
      for (long long j = 1; j <= 3; j++) dist[j][i] = 0;
    }
    for (long long i = 1; i <= m; i++) cin >> p[i];
    sort(p + 1, p + 1 + m);
    long long x, y;
    for (long long i = 1; i <= m; i++) {
      p[i] += p[i - 1];
      cin >> x >> y;
      a[x].push_back(y);
      a[y].push_back(x);
    }
    for (long long i = 1; i <= 3; i++) bfs(i);
    long long res = oo;
    for (long long i = 1; i <= n; i++) {
      long long sum = p[dist[2][i]] * 2;
      long long pos = dist[1][i] + dist[3][i];
      if (dist[2][i] + pos > m) continue;
      sum += p[dist[2][i] + pos] - p[dist[2][i]];
      res = min(res, sum);
    }
    cout << res << endl;
  }
  return 0;
}
