#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-9;
vector<long long> g[200001];
vector<vector<long long>> level;
void bfs(long long a, long long f) {
  queue<long long> bfs;
  bfs.push(a);
  level[f][a] = 0;
  while (!bfs.empty()) {
    long long u = bfs.front();
    bfs.pop();
    for (long long i = 0; i < g[u].size(); i++)
      if (level[f][g[u][i]] == -1)
        level[f][g[u][i]] = level[f][u] + 1, bfs.push(g[u][i]);
  }
}
int main() {
  long long t, n, a, b, c, i, m, u, v;
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    vector<long long> cost(m + 1, 0);
    for (i = 1; i <= n; i++) g[i].clear();
    level = vector<vector<long long>>(3, vector<long long>(n + 1, -1));
    for (i = 1; i <= m; i++) cin >> cost[i];
    for (i = 1; i <= m; i++) {
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    bfs(a, 0);
    bfs(b, 1);
    bfs(c, 2);
    sort(cost.begin() + 1, cost.end());
    for (i = 1; i <= m; i++) cost[i] += cost[i - 1];
    long long ans = LLONG_MAX;
    for (i = 1; i <= n; i++) {
      long long x = level[0][i] + level[1][i] + level[2][i];
      if (x <= m) ans = min(ans, cost[x] + cost[level[1][i]]);
    }
    cout << ans << '\n';
  }
}
