#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
int n, m, a, b, c;
int h[N], ne[N], e[N], idx;
int da[200010], db[200010], dc[200010];
int w[N];
long long s[N];
void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; }
void init() {
  memset(da, 0x3f, sizeof da);
  memset(db, 0x3f, sizeof db);
  memset(dc, 0x3f, sizeof dc);
  memset(h, -1, sizeof h);
}
void bfs(int dis[], int x) {
  queue<int> q;
  dis[x] = 0;
  q.push(x);
  while (q.size()) {
    int t = q.front();
    q.pop();
    int i;
    for (i = h[t]; i != -1; i = ne[i]) {
      int j = e[i];
      if (dis[j] > dis[t] + 1) {
        dis[j] = dis[t] + 1;
        q.push(j);
      }
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    init();
    int i;
    cin >> n >> m >> a >> b >> c;
    for (i = 1; i <= m; i++) {
      scanf("%d", &w[i]);
    }
    sort(w + 1, w + 1 + m);
    for (i = 1; i <= m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      add(u, v);
      add(v, u);
    }
    bfs(da, a);
    bfs(db, b);
    bfs(dc, c);
    for (i = 1; i <= m; i++) {
      s[i] = s[i - 1] + w[i];
    }
    long long ans = 1e18;
    for (i = 1; i <= n; i++) {
      if (da[i] + db[i] + dc[i] > m) continue;
      ans = min(ans, 1ll * s[db[i]] + s[db[i] + da[i] + dc[i]]);
    }
    cout << ans << endl;
  }
}
