#include <bits/stdc++.h>
using namespace std;
void stime(chrono::high_resolution_clock::time_point &st) {
  st = chrono::high_resolution_clock::now();
}
void ptime(chrono::high_resolution_clock::time_point &st) {
  clog << "Execution Time: "
       << (int)((chrono::high_resolution_clock::now() - st).count() / 1000000)
       << " ms" << endl;
}
string PROBLEM_NAME = "Weights Distributing";
const int MOD = 998244353;
vector<int> dist;
vector<vector<int> > conns;
int bfs_call;
vector<int> bfs(int start) {
  vector<int> queue;
  queue.push_back(start);
  int index = 0;
  vector<int> cost(dist.size(), -1);
  cost[start] = 0;
  while (index < queue.size()) {
    int state = queue[index];
    index += 1;
    for (int next : conns[state]) {
      if (cost[next] != -1) {
        continue;
      }
      cost[next] = cost[state] + 1;
      queue.push_back(next);
    }
  }
  for (int i = 1; i < dist.size(); i++) {
    dist[i] += cost[i];
  }
  return cost;
};
int main() {
  chrono::high_resolution_clock::time_point start_time;
  stime(start_time);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  long long temp1, temp2;
  for (int iter = 1; iter <= t; iter++) {
    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    vector<long long> prices;
    prices.push_back(0);
    conns = vector<vector<int> >(n + 1);
    dist = vector<int>(n + 1, 0);
    for (int i = 1; i <= m; i++) {
      cin >> temp1;
      prices.push_back(temp1);
    }
    for (int i = 0; i < m; i++) {
      cin >> temp1 >> temp2;
      conns[temp1].push_back(temp2);
      conns[temp2].push_back(temp1);
    }
    sort(prices.begin(), prices.end());
    for (int i = 1; i < prices.size(); i++) {
      prices[i] += prices[i - 1];
    }
    bfs(a);
    vector<int> b_costs = bfs(b);
    bfs(c);
    long long ans = -1;
    for (int i = 1; i <= n; i++) {
      if (dist[i] > m) {
        continue;
      }
      long long cur = prices[dist[i]];
      cur += prices[b_costs[i]];
      if (ans == -1 || cur < ans) {
        ans = cur;
      }
    }
    cout << ans << endl;
  }
}
