#include <bits/stdc++.h>
using namespace std;
vector<int> bfs(int i, vector<vector<int>>& edges) {
  int n = edges.size() - 1;
  vector<int> res(n + 1, -1), vis(n + 1, 0);
  queue<int> q;
  q.push(i);
  vis[i] = 1;
  res[i] = 0;
  while (!q.empty()) {
    int sz = q.size();
    for (int j = 0; j < sz; ++j) {
      int p = q.front();
      q.pop();
      for (auto e : edges[p]) {
        if (!vis[e]) {
          q.push(e);
          res[e] = res[p] + 1;
          vis[e] = 1;
        }
      }
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  for (int i = 1; i <= T; ++i) {
    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    vector<long long> vi(m);
    vector<vector<int>> edges(n + 1);
    for (int i = 0; i < m; ++i) cin >> vi[i];
    for (int i = 1; i <= m; ++i) {
      int p, q;
      cin >> p >> q;
      edges[p].push_back(q);
      edges[q].push_back(p);
    }
    vector<int> da = bfs(a, edges);
    vector<int> db = bfs(b, edges);
    vector<int> dc = bfs(c, edges);
    vector<long long> sum(m + 1);
    sort(vi.begin(), vi.end());
    sum[0] = 0;
    for (int i = 1; i <= m; ++i) sum[i] = sum[i - 1] + vi[i - 1];
    long long res = 2e18;
    for (int i = 1; i <= n; ++i) {
      int pa = da[i], pb = db[i], pc = dc[i];
      if (pa + pb + pc > m) continue;
      long long r = sum[pa + pb + pc] + sum[pb];
      res = min(res, r);
    }
    cout << res << endl;
  }
  return 0;
}
