#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, c, cnt;
int dis[3][200005], head[400005];
long long p[200005];
long long ans;
struct node {
  int to, next;
} e[400005];
void add(int x, int y) {
  e[++cnt].to = y;
  e[cnt].next = head[x];
  head[x] = cnt;
}
void bfs(int u, int *dis) {
  queue<int> q;
  q.push(u);
  dis[u] = 1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = head[v]; i; i = e[i].next) {
      int y = e[i].to;
      if (!dis[y]) {
        dis[y] = dis[v] + 1;
        q.push(y);
      }
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    ans = 1e18;
    cin >> n >> m >> a >> b >> c, cnt = 0;
    for (int i = 1; i <= m; i++) cin >> p[i];
    sort(p + 1, p + m + 1);
    for (int i = 1; i <= n; i++)
      dis[0][i] = dis[1][i] = dis[2][i] = head[i] = 0;
    for (int i = 1; i <= m; i++) p[i] += p[i - 1];
    for (int i = 1; i <= m; i++) {
      int u, v;
      cin >> u >> v;
      add(u, v), add(v, u);
    }
    bfs(a, dis[0]), bfs(b, dis[1]), bfs(c, dis[2]);
    for (int i = 1; i <= n; i++) {
      if (dis[0][i] + dis[1][i] + dis[2][i] <= m + 3)
        ans = min(ans, p[dis[1][i] - 1] +
                           p[dis[0][i] - 1 + dis[1][i] - 1 + dis[2][i] - 1]);
    }
    cout << ans << endl;
  }
}
