#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005];
int vis[200005];
void fun(int u, vector<int> &d, int n) {
  memset(vis, 0, sizeof(int) * (n + 1));
  queue<int> q;
  q.push(u);
  vis[u] = 1;
  d[u] = 0;
  int level = 0;
  while (!q.empty()) {
    int x = q.size();
    while (x--) {
      int node = q.front();
      d[node] = level;
      q.pop();
      for (auto y : v[node]) {
        if (vis[y] == 0) {
          vis[y] = 1;
          q.push(y);
        }
      }
    }
    level++;
  }
}
int main() {
  long long n, m, i, j, t, x, y, w, k, a, b, c;
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b >> c;
    vector<long long> p;
    for (i = 0; i < m; i++) {
      cin >> x;
      p.push_back(x);
    }
    for (i = 0; i < m; i++) {
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    vector<int> d1(n + 1), d2(n + 1), d3(n + 1);
    fun(a, d1, n);
    fun(b, d2, n);
    fun(c, d3, n);
    sort(p.begin(), p.end());
    long long sum = 0;
    int temp = d2[a] + d2[c];
    long long ans = 99999999999999999;
    if (temp < m) {
      for (i = 0; i < temp; i++) {
        sum += p[i];
      }
      ans = sum;
    }
    for (i = 1; i < m; i++) {
      p[i] += p[i - 1];
    }
    for (i = 1; i <= n; i++) {
      long long sum = 99999999999999999;
      int dist = d1[i] + d2[i] + d3[i];
      if (dist <= m && dist >= 1) {
        sum = p[dist - 1] + ((d2[i] > 0) ? p[d2[i] - 1] : 0);
        ans = min(ans, sum);
      }
    }
    cout << ans << "\n";
    for (i = 1; i <= n; i++) {
      v[i].clear();
    }
  }
  return 0;
}
