#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& a) {
  os << "(" << a.first << ", " << a.second << ")";
  return os;
}
const char newl = '\n';
void bfs(int i, vector<int>& dist, vector<vector<int>>& edges) {
  queue<int> que;
  que.push(i);
  dist[i] = 0;
  while (!que.empty()) {
    int t = que.front();
    que.pop();
    for (int j : edges[t])
      if (dist[j] > dist[t] + 1) {
        que.push(j);
        dist[j] = dist[t] + 1;
      }
  }
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n, m, a, b, c;
    scanf("%d%d%d%d%d", &n, &m, &a, &b, &c);
    a--;
    b--;
    c--;
    vector<long long> p(m + 1);
    vector<int> dist1(n, 1e9), dist2(n, 1e9), dist3(n, 1e9);
    vector<vector<int>> edges(n);
    for (int i = 0; i < m; ++i) scanf("%lld", &p[i + 1]);
    sort(p.begin(), p.end());
    for (int i = 0; i < m; ++i) p[i + 1] += p[i];
    for (int i = 0; i < m; ++i) {
      int u, v;
      scanf("%d%d", &u, &v);
      u--;
      v--;
      edges[u].push_back(v);
      edges[v].push_back(u);
    }
    bfs(a, dist1, edges);
    bfs(b, dist2, edges);
    bfs(c, dist3, edges);
    long long ans = 1e18;
    for (int i = 0; i < n; ++i) {
      int x = dist1[i] + dist2[i] + dist3[i];
      if (x > m) continue;
      ans = min(ans, p[x] + p[dist2[i]]);
    }
    cout << ans << newl;
  }
}
