#include <bits/stdc++.h>
using namespace std;
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
vector<vector<int> > adj;
void bfs(int x, vector<int>& d) {
  queue<int> Q;
  Q.push(x);
  d[x] = 0;
  while (!Q.empty()) {
    int a;
    a = Q.front();
    Q.pop();
    for (int i = 0; i < adj[a].size(); i++) {
      if (d[adj[a][i]] == (int)1e9) {
        d[adj[a][i]] = 1 + d[a];
        Q.push(adj[a][i]);
      }
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, a, b, c;
    long long min1 = (long long)1e18;
    cin >> n >> m >> a >> b >> c;
    long long p[m + 1], pre[m + 1];
    for (long long i = 0; i < m; i += 1) cin >> p[i + 1];
    sort(p + 1, p + m + 1);
    pre[1] = p[1];
    pre[0] = 0;
    for (int i = 2; i <= m; i++) pre[i] = pre[i - 1] + p[i];
    adj = vector<vector<int> >(n + 1);
    for (long long i = 0; i < m; i += 1) {
      int x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    vector<int> da(n + 1, (int)1e9), db(n + 1, (int)1e9), dc(n + 1, (int)1e9);
    bfs(a, da);
    bfs(b, db);
    bfs(c, dc);
    for (int i = 1; i <= n; i++) {
      if (da[i] + db[i] + dc[i] > m) continue;
      min1 = min(min1, pre[db[i]] + pre[da[i] + db[i] + dc[i]]);
    }
    cout << min1 << "\n";
  }
}
