#include <bits/stdc++.h>
using namespace std;
int t, n, m, a, b, c;
int da[200005], db[200005], dc[200005];
long long cost[200005];
vector<int> G[200005];
void bfs(int k, int d[]) {
  d[k] = 0;
  queue<int> q;
  q.push(k);
  while (q.empty() == false) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < G[x].size(); i++) {
      int y = G[x][i];
      if (d[y] == -1) {
        q.push(y);
        d[y] = d[x] + 1;
      }
    }
  }
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    for (int i = 1; i <= m; i++) cin >> cost[i];
    sort(cost + 1, cost + m + 1);
    for (int i = 1; i <= m; i++) cost[i] = cost[i] + cost[i - 1];
    for (int i = 1; i <= m; i++) {
      int x, y;
      cin >> x >> y;
      G[x].push_back(y);
      G[y].push_back(x);
    }
    for (int i = 1; i <= n; i++) da[i] = db[i] = dc[i] = -1;
    bfs(a, da);
    bfs(b, db);
    bfs(c, dc);
    long long ans = 1e18;
    for (int i = 1; i <= n; i++) {
      if (da[i] + db[i] + dc[i] <= m) {
        ans = min(ans, cost[db[i]] + cost[da[i] + db[i] + dc[i]]);
      }
    }
    for (int i = 1; i <= n; i++) G[i].clear();
    cout << ans << "\n";
  }
  return 0;
}
