#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005 + 1];
int dist[3][200005 + 1], n;
long long prices[200005 + 1];
bool picked[200005 + 1];
void sp(int x, int ix) {
  for (int i = 1; i <= n; ++i) dist[ix][i] = INT_MAX, picked[i] = false;
  dist[ix][x] = 0;
  set<pair<int, int> > st;
  st.insert(make_pair(0, x));
  while (!st.empty()) {
    int pick = st.begin()->second;
    st.erase(st.begin());
    picked[pick] = true;
    for (int i = 0; i < v[pick].size(); ++i) {
      if (!picked[v[pick][i]]) {
        if (dist[ix][v[pick][i]] > dist[ix][pick] + 1) {
          st.erase(make_pair(dist[ix][v[pick][i]], v[pick][i]));
          dist[ix][v[pick][i]] = dist[ix][pick] + 1;
          st.insert(make_pair(dist[ix][v[pick][i]], v[pick][i]));
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    for (int i = 1; i <= m; ++i) cin >> prices[i];
    sort(prices + 1, prices + m + 1);
    prices[0] = 0;
    for (int i = 1; i <= m; ++i) prices[i] += prices[i - 1];
    for (int i = 1; i <= n; ++i) v[i].clear();
    for (int i = 0, x, y; i < m; ++i)
      cin >> x >> y, v[x].push_back(y), v[y].push_back(x);
    sp(a, 0), sp(b, 1), sp(c, 2);
    long long ans = LLONG_MAX;
    for (int i = 1; i <= n; ++i)
      if (dist[1][i] + dist[0][i] + dist[2][i] <= m)
        ans = min(ans, prices[dist[1][i]] +
                           prices[dist[1][i] + dist[0][i] + dist[2][i]]);
    cout << ans << endl;
  }
  return 0;
}
