#include <bits/stdc++.h>
using namespace std;
template <typename T>
using COUPLE = array<T, 2>;
template <typename T>
using TRIPLE = array<T, 3>;
template <typename T>
using QUAD = array<T, 4>;
using Byte = unsigned char;
using LLD = long long;
using ULLD = unsigned long long;
using UINT = unsigned int;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VPII = vector<PII>;
using MII = map<int, int>;
using SI = set<int>;
using VVP = vector<VPII>;
using PLLD = pair<LLD, LLD>;
using VLLD = vector<LLD>;
using VVLLD = vector<VLLD>;
using VPLLD = vector<PLLD>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VCh = vector<char>;
using VVCh = vector<VCh>;
using CI = COUPLE<int>;
using TI = TRIPLE<int>;
using QI = QUAD<int>;
using VCI = vector<CI>;
using VTI = vector<TI>;
using VQI = vector<QI>;
template <size_t n>
using INTARR = array<int, n>;
const int INF = 2147483647 / 2;
const LLD LLDINF = INT64_MAX / 2;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
int operator~(const string& s) { return (int)(s.size()); }
char& operator^(string& s, int v) { return s[~s - 1 - v]; }
char& operator-(string& s) { return s[~s - 1]; }
template <typename T, typename... Args>
void operator+=(vector<T, Args...>& s, T v) {
  s.push_back(v);
}
template <typename T, typename... Args>
T& operator-(vector<T, Args...>& s) {
  return s[~s - 1];
}
template <typename T, typename... Args>
T& operator^(vector<T, Args...>& s, int v) {
  return s[~s - 1 - v];
}
template <typename T, typename... Args>
T operator--(vector<T, Args...>& s) {
  auto k = -s;
  s.pop_back();
  return move(k);
}
template <typename T, typename... Args>
int operator~(const vector<T, Args...>& s) {
  return (int)s.size();
}
template <typename T, typename... Args>
void dedup(vector<T, Args...>& s) {
  sort((s).begin(), (s).end());
  s.erase(unique((s).begin(), (s).end()), s.end());
}
template <typename T, typename... Args>
typename vector<T, Args...>::iterator find(vector<T, Args...>& s, const T& x) {
  auto it = lower_bound((s).begin(), (s).end(), x);
  return (it != s.end() && *it == x) ? it : s.end();
}
template <typename T, typename... Args>
int index(vector<T, Args...>& s, const T& x) {
  auto it = find(s, x);
  check(it != s.end() && *it == x);
  return it - s.begin();
}
template <typename T, size_t n>
int operator~(const array<T, n>& s) {
  return (int)s.size();
}
template <typename T, typename... Args>
void operator+=(stack<T, Args...>& s, T v) {
  s.push(v);
}
template <typename T, typename... Args>
T& operator-(stack<T, Args...>& s) {
  return s.top();
}
template <typename T, typename... Args>
T operator--(stack<T, Args...>& s) {
  auto k = -s;
  s.pop();
  return move(k);
}
template <typename T, typename... Args>
int operator~(const stack<T, Args...>& s) {
  return (int)s.size();
}
template <typename T, typename... Args>
void operator+=(queue<T, Args...>& s, T v) {
  s.push(v);
}
template <typename T, typename... Args>
T& operator-(queue<T, Args...>& s) {
  return s.front();
}
template <typename T, typename... Args>
T operator--(queue<T, Args...>& s) {
  auto k = -s;
  s.pop();
  return move(k);
}
template <typename T, typename... Args>
int operator~(const queue<T, Args...>& s) {
  return (int)s.size();
}
template <typename T, typename... Args>
void operator+=(priority_queue<T, Args...>& s, T v) {
  s.push(v);
}
template <typename T, typename... Args>
T& operator-(priority_queue<T, Args...>& s) {
  return s.top();
}
template <typename T, typename... Args>
T operator--(priority_queue<T, Args...>& s) {
  auto k = -s;
  s.pop();
  return move(k);
}
template <typename T, typename... Args>
int operator~(const priority_queue<T, Args...>& s) {
  return (int)s.size();
}
template <typename T, typename... Args>
void operator+=(set<T, Args...>& s, T v) {
  s.insert(v);
}
template <typename T, typename... Args>
void operator-=(set<T, Args...>& s, T v) {
  s.erase(v);
}
template <typename T, typename... Args>
bool operator<(T v, set<T, Args...>& s) {
  return s.find(v) != s.end();
}
template <typename T, typename... Args>
bool operator>(T v, set<T, Args...>& s) {
  return s.find(v) == s.end();
}
template <typename T, typename... Args>
int operator~(const set<T, Args...>& s) {
  return (int)s.size();
}
template <typename K, typename V>
void operator+=(map<K, V>& s, pair<K, V> v) {
  s.insert(v);
}
template <typename K, typename V>
void operator-=(map<K, V>& s, K v) {
  s.erase(v);
}
template <typename T, typename... Args>
bool operator<(T v, const map<T, Args...>& s) {
  return s.find(v) != s.end();
}
template <typename T, typename... Args>
bool operator>(T v, const map<T, Args...>& s) {
  return s.find(v) == s.end();
}
template <typename T, typename... Args>
int operator~(const map<T, Args...>& s) {
  return (int)s.size();
}
template <typename T>
void __pvec(T& v) {}
template <typename T>
void __p2vec(T& v) {}
template <typename T>
void __pmat(T& v) {}
template <typename K, typename V>
void read(pair<K, V>& p);
template <typename T>
void read(vector<T>& v);
template <typename T>
void read(T& x);
template <typename T, typename... Args>
void read(T& head, Args&... rest);
template <typename K, typename V>
void read(pair<K, V>& p) {
  read(p.first, p.second);
}
template <typename T>
void read(vector<T>& v) {
  for (int i = 0; i < (~v); ++i) cin >> v[i];
}
template <typename T>
void read(T& x) {
  cin >> x;
}
template <typename T, typename... Args>
void read(T& head, Args&... rest) {
  read(head);
  read(rest...);
}
const char* __sep__[2] = {", ", " "};
template <typename... Args>
ostream& operator<<(ostream& os, const vector<Args...>& v) {
  os << "[ ";
  for (int i = 0; i < (~v); ++i) {
    os << v[i] << __sep__[i + 1 == ~v];
  }
  return os << "]";
}
template <typename T, size_t n>
ostream& operator<<(ostream& os, const array<T, n>& v) {
  os << "[ ";
  for (int i = 0; i < (~v); ++i) {
    os << v[i] << __sep__[i + 1 == ~v];
  }
  return os << "]";
}
template <typename... Args>
ostream& operator<<(ostream& os, const set<Args...>& v) {
  os << "{ ";
  for (auto it = (v).begin(); it != (v).end(); ++it)
    os << *it << __sep__[next(it) == v.end()];
  return os << "}";
}
template <typename K, typename V>
ostream& operator<<(ostream& os, const map<K, V>& v) {
  os << "{ ";
  for (auto it = (v).begin(); it != (v).end(); ++it)
    os << it->first << ": " << it->second << __sep__[next(it) == v.end()];
  return os << "}";
}
template <typename K, typename V>
ostream& operator<<(ostream& os, const pair<K, V>& v) {
  return os << "(" << v.first << __sep__[0] << v.second << ")";
}
template <typename K, typename V>
ostream& operator<<(ostream& os, const tuple<K, V>& v) {
  return os << "(" << tget(v, 0) << __sep__[0] << tget(v, 1) << ")";
}
template <typename K, typename V, typename T>
ostream& operator<<(ostream& os, const tuple<K, V, T>& v) {
  return os << "(" << tget(v, 0) << __sep__[0] << tget(v, 1) << __sep__[0]
            << tget(v, 2) << ")";
}
template <typename T>
void __swrite(const char* sep, const T& x) {
  cout << x << sep;
}
template <typename T, typename... Args>
void __swrite(const char* sep, const T& x, const Args&... a) {
  cout << x << sep;
  __swrite(sep, a...);
}
template <typename... Args>
void writeln(const Args&... a) {
  __swrite("\n", a...);
}
void writeln() { cout << "\n"; }
template <typename... Args>
void writes(const Args&... a) {
  __swrite(" ", a...);
}
template <typename... Args>
void writesln(const Args&... a) {
  __swrite(" ", a...);
  writeln();
}
template <typename... Args>
void write(const Args&... a) {
  __swrite("", a...);
}
template <typename T, typename... Args>
void mkmax(T& a, Args&&... z) {
  a = max({a, z...});
}
template <typename T, typename... Args>
void mkmin(T& a, Args&&... z) {
  a = min({a, z...});
}
template <typename T, typename... Args>
bool ckmax(T& a, Args&&... z) {
  auto t = a;
  mkmax(a, z...);
  return (a != t);
}
template <typename T, typename... Args>
bool ckmin(T& a, Args&&... z) {
  auto t = a;
  mkmin(a, z...);
  return (a != t);
}
int log2_floor(UINT n) { return 31 - __builtin_clz(n); }
int log2_ceil(UINT n) { return log2_floor(n) + !!(n & (n - 1)); }
int log2_floor64(ULLD n) { return 63 - __builtin_clzll(n); }
int log2_ceil64(ULLD n) { return log2_floor64(n) + !!(n & (n - 1ULL)); }
template <size_t n>
bitset<n> reverse_bitset(const bitset<n>& x) {
  auto y = x.to_string();
  reverse((y).begin(), (y).end());
  return bitset<n>(y);
}
class Rng {
  mt19937 mtgen;
  uniform_int_distribution<int> dist_;

 public:
  Rng(int min, int max, size_t seed = random_device()())
      : mtgen(seed), dist_(min, max) {}
  int operator()() { return dist_(mtgen); }
};
VI randomvec(int sz) {
  Rng rg(0, 10);
  VI s;
  for (int i = 0; i < (sz); ++i) s += rg();
  return s;
}
string randomstring(int sz) {
  Rng rg((int)'a', (int)'z');
  string s;
  for (int i = 0; i < (sz); ++i) s += (char)rg();
  return s;
}
void measure(const string& name, function<void()> func) {
  auto start_time = chrono::high_resolution_clock::now();
  func();
  auto duration = chrono::duration_cast<chrono::nanoseconds>(
      chrono::high_resolution_clock::now() - start_time);
  ;
}
void soln(int __ntc, int __tc) {
  int n, m;
  read(n, m);
  ;
  int a, b, c;
  read(a, b, c);
  ;
  --a, --b, --c;
  VLLD P(m);
  read(P);
  ;
  VVI g(n);
  for (int _ = 0; _ < (m); ++_) {
    int u, v;
    read(u, v);
    ;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  VI dista(n, -1), distb(n, -1), distc(n, -1);
  auto bfs = [&](int s, VI& dist) {
    dist[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
      int u = --q;
      ;
      for (auto& v : g[u]) {
        ;
        if (dist[v] == -1) {
          dist[v] = dist[u] + 1;
          q.push(v);
        }
      }
    }
  };
  bfs(a, dista), bfs(b, distb), bfs(c, distc);
  sort((P).begin(), (P).end());
  ;
  VLLD pref(m + 1, 0);
  for (int i = 1; i <= m; ++i) {
    pref[i] = pref[i - 1] + P[i - 1];
  }
  LLD ans = LLDINF;
  for (int i = 0; i < n; ++i) {
    int da = dista[i], db = distb[i], dc = distc[i];
    if (da + db + dc > m) continue;
    mkmin(ans, pref[db] + pref[da + db + dc]);
  }
  writeln(ans);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  cin >> tc;
  for (int i = 0; i < tc; ++i) {
    ;
    soln(tc, i + 1);
  }
}
