#include <bits/stdc++.h>
using namespace std;
int t, n, m, ans, a, b, c;
long long p[200005];
vector<int> ke[200005];
struct banghi {
  int s, F[200005];
  void Init() {
    for (int i = 1; i <= n; ++i) F[i] = 1e9;
    F[s] = 0;
    priority_queue<pair<int, int> > hmin;
    hmin.push(make_pair(0, s));
    while (hmin.size()) {
      int x = hmin.top().second;
      int c = -hmin.top().first;
      hmin.pop();
      if (c != F[x]) continue;
      for (auto v : ke[x]) {
        if (F[v] > F[x] + 1) {
          F[v] = F[x] + 1;
          hmin.push(make_pair(-F[v], v));
        }
      }
    }
  }
} Ta, Tb, Tc;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    long long ans = 1e18;
    cin >> n >> m >> a >> b >> c;
    for (int i = 1; i <= m; ++i) cin >> p[i];
    sort(p + 1, p + 1 + m);
    for (int i = 1; i <= m; ++i) p[i] += p[i - 1];
    Ta.s = a;
    Tb.s = b;
    Tc.s = c;
    for (int i = 1; i <= m; ++i) {
      int x, y;
      cin >> x >> y;
      ke[x].push_back(y);
      ke[y].push_back(x);
    }
    Ta.Init();
    Tb.Init();
    Tc.Init();
    for (int i = 1; i <= n; ++i) {
      int x1 = Ta.F[i];
      int x2 = Tb.F[i];
      int x3 = Tc.F[i];
      if (x1 + x2 + x3 > m) continue;
      long long cur = p[min(m, x1 + x2 + x3)] + p[x2];
      ans = min(ans, cur);
    }
    cout << ans << endl;
    for (int i = 1; i <= n; ++i) ke[i].clear();
  }
  return 0;
}
