#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using namespace std;
long long modu = 1e9 + 7;
void update_shortest_path(int par, int ind, vector<vector<long long> > &mnmdist,
                          int n, vector<vector<long long> > &child) {
  vector<bool> vis(n + 1);
  vis[par] = 1;
  mnmdist[par][ind] = 0;
  deque<int> q;
  q.push_back(par);
  int wid = 1, twid, dist = 1;
  while (!q.empty()) {
    twid = 0;
    for (int i = 0; i < wid; i++) {
      int curpar = q.front(), curchild;
      q.pop_front();
      for (int j = 0; j < child[curpar].size(); j++) {
        curchild = child[curpar][j];
        if (!vis[curchild]) {
          mnmdist[curchild][ind] = dist;
          q.push_back(curchild);
          vis[curchild] = 1;
          twid++;
        }
      }
    }
    wid = twid;
    dist++;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m, a, b, c, ans = 1e18 + 7;
    cin >> n >> m >> a >> b >> c;
    vector<long long> price(m + 1, 0);
    vector<vector<long long> > child(n + 1);
    vector<long long> temp(3, 0);
    vector<vector<long long> > mnmdist(n + 1, temp);
    for (int i = 1; i <= m; i++) cin >> price[i];
    int x, y;
    for (int i = 0; i < m; i++) {
      cin >> x >> y;
      child[x].push_back(y);
      child[y].push_back(x);
    }
    sort(price.begin(), price.end());
    for (int i = 1; i <= m; i++) price[i] += price[i - 1];
    update_shortest_path(a, 0, mnmdist, n, child);
    update_shortest_path(b, 1, mnmdist, n, child);
    update_shortest_path(c, 2, mnmdist, n, child);
    vector<long long> cur(3);
    for (int i = 1; i <= n; i++) {
      cur = mnmdist[i];
      if (cur[0] + cur[1] + cur[2] <= m)
        ans = min(ans, price[cur[0] + cur[1] + cur[2]] + price[cur[1]]);
    }
    cout << ans << endl;
  }
}
