#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (x == 0) return y;
  return gcd(y % x, x);
}
long long powmod(long long x, long long y, long long m) {
  long long ans = 1, r = 1;
  x %= m;
  while (r > 0 && r <= y) {
    if (r & y) {
      ans *= x;
      ans %= m;
    }
    r <<= 1;
    x *= x;
    x %= m;
  }
  return ans;
}
long long mul_inv(long long a, long long b) {
  long long b0 = b, t, q;
  long long x0 = 0ll, x1 = 1ll;
  if (b == 1ll) return 1ll;
  while (a > 1ll) {
    q = a / b;
    t = b, b = a % b, a = t;
    t = x0, x0 = x1 - q * x0, x1 = t;
  }
  if (x1 < 0ll) x1 += b0;
  return x1;
}
bool bdec(long long &x, long long &y) { return x > y; }
vector<vector<long long> > id(long long n) {
  vector<vector<long long> > temp;
  temp.resize(n);
  for (int i = 0; i < n; i++) {
    temp[i].resize(n);
    temp[i][i] = 1;
  }
  return temp;
}
vector<vector<long long> > mul(vector<vector<long long> > &x,
                               vector<vector<long long> > &y) {
  long long a = x.size(), b = x[0].size(), c = y.size(), d = y[0].size();
  vector<vector<long long> > ans;
  if (b != c) {
    cout << "invalid\n";
    exit(0);
  }
  ans.resize(a);
  for (int i = 0; i < a; i++) {
    ans[i].resize(d);
    for (int k = 0; k < b; k++) {
      for (int t = 0; t < d; t++) {
        ans[i][t] += x[i][k] * y[k][t];
        ans[i][t] %= 1000000007;
      }
    }
  }
  return ans;
}
vector<vector<long long> > powmat(vector<vector<long long> > x, long long n,
                                  long long m) {
  vector<vector<long long> > ans = id(x.size());
  while (n > 0) {
    if (n & 1ll) {
      ans = mul(ans, x);
    }
    x = mul(x, x);
    n >>= 1ll;
  }
  return ans;
}
const long long maxn = 2e5 + 2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long te;
  cin >> te;
  while (te--) {
    long long n, m;
    cin >> n >> m;
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c--;
    long long d[m];
    for (int i = 0; i < m; i++) cin >> d[i];
    sort(d, d + m);
    vector<vector<long long> > gr(n);
    for (int i = 0; i < m; i++) {
      long long x, y;
      cin >> x >> y;
      x--;
      y--;
      gr[x].push_back(y);
      gr[y].push_back(x);
    }
    vector<long long> vis(n, 0ll);
    vector<long long> disb(n, 0ll);
    vis[b] = 1;
    vector<long long> k;
    k.push_back(b);
    long long it = 0;
    while (it != k.size()) {
      for (auto x : gr[k[it]]) {
        if (vis[x]) continue;
        vis[x] = 1;
        k.push_back(x);
        disb[x] = disb[k[it]] + 1;
      }
      it++;
    }
    if (a == b && b == c) {
      cout << 0 << "\n";
      continue;
    }
    vis.clear();
    vis.resize(n);
    k.clear();
    it = 0;
    k.push_back(a);
    vis[a] = 1;
    vector<long long> disa(n, 0ll);
    while (k.size() != it) {
      for (auto x : gr[k[it]]) {
        if (vis[x]) continue;
        vis[x] = 1;
        disa[x] = disa[k[it]] + 1;
        k.push_back(x);
      }
      it++;
    }
    vis.clear();
    vis.resize(n);
    k.clear();
    it = 0;
    k.push_back(c);
    vis[c] = 1;
    vector<long long> disc(n, 0ll);
    while (k.size() != it) {
      for (auto x : gr[k[it]]) {
        if (vis[x]) continue;
        vis[x] = 1;
        disc[x] = disc[k[it]] + 1;
        k.push_back(x);
      }
      it++;
    }
    long long t = 1e18;
    long long temp[m];
    temp[0] = d[0];
    for (int i = 1; i < m; i++) {
      temp[i] = temp[i - 1] + d[i];
    }
    for (int i = 0; i < n; i++) {
      if (i == b) {
        long long f = disa[i] + disc[i] + disb[i];
        f--;
        if (f >= m) continue;
        t = min(t, temp[f]);
        continue;
      }
      long long x = disb[i];
      long long cnt = 0;
      x--;
      cnt += temp[x] + temp[x];
      long long f = disa[i] + disc[i] + disb[i];
      f--;
      if (f >= m) continue;
      cnt += temp[f] - temp[x];
      t = min(t, cnt);
    }
    cout << t << "\n";
  }
  return 0;
}
