#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m, a, b, c;
    scanf("%d%d%d%d%d", &n, &m, &a, &b, &c);
    a--;
    b--;
    c--;
    vector<long long> p(m + 1);
    p[0] = 0;
    for (int i = 1; i <= m; i++) scanf("%lld", &p[i]);
    sort(p.begin() + 1, p.end());
    for (int i = 1; i <= m; i++) {
      p[i] += p[i - 1];
    }
    vector<vector<int> > adjLis(n);
    for (int i = m; i--;) {
      int u, v;
      scanf("%d%d", &u, &v);
      u--;
      v--;
      adjLis[u].push_back(v);
      adjLis[v].push_back(u);
    }
    vector<int> dista(n, n), distb(n, n), distc(n, n);
    queue<int> bfs;
    dista[a] = 0;
    bfs.push(a);
    while (!bfs.empty()) {
      int x = bfs.front();
      bfs.pop();
      for (int y : adjLis[x]) {
        if (dista[y] != n) continue;
        dista[y] = dista[x] + 1;
        bfs.push(y);
      }
    }
    distb[b] = 0;
    bfs.push(b);
    while (!bfs.empty()) {
      int x = bfs.front();
      bfs.pop();
      for (int y : adjLis[x]) {
        if (distb[y] != n) continue;
        distb[y] = distb[x] + 1;
        bfs.push(y);
      }
    }
    distc[c] = 0;
    bfs.push(c);
    while (!bfs.empty()) {
      int x = bfs.front();
      bfs.pop();
      for (int y : adjLis[x]) {
        if (distc[y] != n) continue;
        distc[y] = distc[x] + 1;
        bfs.push(y);
      }
    }
    long long ans = 200000000000000;
    for (int i = 0; i < n; i++) {
      if (dista[i] + distb[i] + distc[i] <= m)
        ans = min(ans, p[dista[i] + distb[i] + distc[i]] + p[distb[i]]);
    }
    printf("%lld\n", ans);
  }
}
