#include <bits/stdc++.h>
using namespace std;
const int64_t N = 1e6 + 6, M = 1e9 + 7;
const int64_t INF = (1LL << 62) - 1;
vector<int64_t> dijkstra(vector<vector<pair<int64_t, int64_t>>> &G, int64_t v) {
  vector<int64_t> ans(G.size(), INF);
  ans[v] = 0;
  auto cmp = [&](int64_t i, int64_t j) { return ans[i] > ans[j]; };
  priority_queue<int64_t, vector<int64_t>, decltype(cmp)> que(cmp);
  que.push(v);
  while (!que.empty()) {
    auto f = que.top();
    que.pop();
    for (auto i : G[f])
      if (ans[f] + i.second < ans[i.first])
        ans[i.first] = ans[f] + i.second, que.push(i.first);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    int64_t n, m, a, b, c, u, v;
    cin >> n >> m >> a >> b >> c;
    a--, b--, c--;
    vector<vector<pair<int64_t, int64_t>>> g(n);
    vector<int64_t> p(m + 1);
    for (int64_t i = 1; i <= m; i++) cin >> p[i];
    sort(p.begin(), p.end());
    for (int64_t i = 1; i <= m; i++) p[i] += p[i - 1];
    while (m--)
      cin >> u >> v, u--, v--, g[u].push_back({v, 1}), g[v].push_back({u, 1});
    auto x = dijkstra(g, a);
    auto y = dijkstra(g, b);
    auto z = dijkstra(g, c);
    int64_t ans = INF;
    for (int64_t i = 0; i < n; i++) {
      int64_t s = x[i] + y[i] + z[i];
      if (s < p.size()) ans = min(ans, p[s] + p[y[i]]);
    }
    cout << ans << '\n';
  }
}
