#include <bits/stdc++.h>
using namespace std;
void file() {}
const long long N = 2e5 + 5;
vector<long long> G[N];
long long dis[3][N], p[N];
void dijkstra(long long s, long long tag) {
  memset(dis[tag], 0x3f3f3f3f, sizeof(dis[tag]));
  ;
  dis[tag][s] = 0;
  priority_queue<pair<long long, long long> > pri;
  pri.push({0, s});
  while (!pri.empty()) {
    pair<long long, long long> po = pri.top();
    pri.pop();
    if (dis[tag][po.second] < po.first) continue;
    for (auto v : G[po.second]) {
      if (dis[tag][v] > dis[tag][po.second] + 1) {
        dis[tag][v] = dis[tag][po.second] + 1;
        pri.push({-dis[tag][v], v});
      }
    }
  }
}
signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  file();
  long long t;
  cin >> t;
  while (t--) {
    long long n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    for (long long i = 1; i <= n; i++) G[i].clear();
    for (long long i = 1; i <= m; i++) cin >> p[i];
    sort(p + 1, p + 1 + m);
    for (long long i = 1; i <= n; i++) p[i] += p[i - 1];
    while (m--) {
      long long u, v;
      cin >> u >> v;
      G[u].push_back(v);
      G[v].push_back(u);
    }
    dijkstra(a, 0);
    dijkstra(b, 1);
    dijkstra(c, 2);
    long long ans = 0x3f3f3f3f3f3f3f3f;
    for (long long i = 1; i <= n; i++) {
      long long sum1 = dis[0][i] + dis[2][i];
      long long sum2 = dis[1][i];
      if (sum1 + sum2 >= n) continue;
      ans = min(ans, p[sum2] * 2 + p[sum1 + sum2] - p[sum2]);
      ans = min(ans, p[sum1] + (p[sum1 + sum2] - p[sum1]) * 2);
    }
    cout << ans << "\n";
  }
  return 0;
}
