#include <bits/stdc++.h>
using namespace std;
template <class T>
T maxT(T a, T b) {
  return (a > b ? a : b);
}
template <class T>
T minT(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
void setmin(T &a, T b) {
  a = (a > b ? a : b);
}
template <class T>
void setmax(T &a, T b) {
  a = (a < b ? a : b);
}
void fileio() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("debug.txt", "w", stderr);
}
void ofileio() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void clock_out() {
  cerr << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
const long long MOD = 1000000007;
const long long SIZE = 100000;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const long double PI = acos(-1);
const long long MAXN = numeric_limits<long long>::max();
long long n, m, a, b, c;
vector<long long> bfs(long long src, vector<vector<long long>> adj) {
  vector<long long> dist(n, -1);
  dist[src] = 0;
  queue<long long> qu;
  qu.push(src);
  while (!qu.empty()) {
    long long par = qu.front();
    qu.pop();
    for (auto next : adj[par]) {
      if (dist[next] == -1) {
        dist[next] = dist[par] + 1;
        qu.push(next);
      }
    }
  }
  return dist;
}
void solve() {
  cin >> n >> m >> a >> b >> c;
  a--;
  b--;
  c--;
  vector<long long> p(m);
  for (long long i = 0; i < (long long)m; i++) cin >> p[i];
  sort(p.begin(), p.end());
  vector<long long> pref(m + 1, 0);
  for (long long i = (long long)1; i < (long long)m + 1; i++) {
    pref[i] = pref[i - 1] + p[i - 1];
  }
  vector<vector<long long>> adj(n);
  for (long long i = 0; i < (long long)m; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  vector<long long> da = bfs(a, adj);
  vector<long long> db = bfs(b, adj);
  vector<long long> dc = bfs(c, adj);
  long long ans = LLONG_MAX;
  for (long long x = 0; x < n; x++) {
    if ((da[x] + db[x] + dc[x]) <= m) {
      1;
      ans = min(ans, pref[db[x]] + pref[da[x] + db[x] + dc[x]]);
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  1;
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  1;
  return 0;
}
