#include <bits/stdc++.h>
using namespace std;
const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 0, 1, -1};
const int dy4[6] = {1, -1, 0, 0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};
void update(long long &x, long long v) {
  if (x == -1)
    x = v;
  else if (x > v)
    x = v;
}
long long po(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  } else {
    return gcd(b % a, a);
  }
}
void extgcd(long long a, long long b, long long &d, long long &x,
            long long &y) {
  if (!b) {
    d = a;
    x = 1;
  } else {
    extgcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
long long inverse(long long a, long long n) {
  long long d, x, y;
  extgcd(a, n, d, x, y);
  return d == 1 ? (x + n) % n : -1;
}
const int maxn = 2e5 + 15;
const double PI = acos(-1.0);
const long long mod = 1e9 + 7;
constexpr int INF = 0x3f3f3f3f;
struct edge {
  int to, cost;
};
vector<int> dijkstra(const vector<vector<edge>> &g, int s) {
  vector<int> d(g.size() + 5, INF);
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      que;
  d[s] = 0;
  que.emplace(0, s);
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    int u = p.second;
    if (d[u] < p.first) continue;
    for (auto &e : g[u]) {
      int v = e.to;
      if (d[v] > d[u] + e.cost) {
        d[v] = d[u] + e.cost;
        que.emplace(d[v], v);
      }
    }
  }
  return d;
}
long long n, m, a, b, c;
long long p[maxn];
vector<vector<edge>> g;
void solve() {
  scanf("%lld", &(n));
  scanf("%lld", &(m));
  scanf("%lld", &(a));
  scanf("%lld", &(b));
  scanf("%lld", &(c));
  g.resize(n + 5);
  for (int i = 1; i <= n; i++) {
    g[i].clear();
  }
  for (int i = 1; i <= m; i++) {
    scanf("%lld", &(p[i]));
  }
  sort(p + 1, p + m + 1);
  for (int i = 1; i <= m; i++) {
    p[i] += p[i - 1];
  }
  for (int i = 1; i <= m; i++) {
    int h, f;
    scanf("%d", &(h));
    scanf("%d", &(f));
    g[h].push_back(edge{f, 1});
    g[f].push_back(edge{h, 1});
  }
  std::vector<int> dis1 = dijkstra(g, a);
  std::vector<int> dis2 = dijkstra(g, b);
  std::vector<int> dis3 = dijkstra(g, c);
  long long ans = 0x3fffffffffffffff;
  for (int i = 1; i <= n; i++) {
    if (dis1[i] + dis2[i] + dis3[i] > m) {
      continue;
    }
    ans = min(ans, p[dis1[i] + dis2[i] + dis3[i]] + p[dis2[i]]);
  }
  printf("%lld\n", ans);
}
int main() {
  int t;
  scanf("%d", &(t));
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
