#include <bits/stdc++.h>   using namespace std;   template <typename Arg1, typename Arg2>   ostream& operator<<(ostream& out, const pair<Arg1, Arg2>& x) {     return out <<  (  << x.first <<  ,  << x.second <<  ) ;   }   template <typename Arg1>   ostream& operator<<(ostream& out, const vector<Arg1>& a) {     out <<  [ ;     for (const auto& x : a) out << x <<  , ;     return out <<  ] ;   }   template <typename Arg1>   ostream& operator<<(ostream& out, const set<Arg1>& a) {     out <<  [ ;     for (const auto& x : a) out << x <<  , ;     return out <<  ] ;   }   template <typename Arg1, typename Arg2>   ostream& operator<<(ostream& out, const map<Arg1, Arg2>& a) {     out <<  [ ;     for (const auto& x : a) out << x <<  , ;     return out <<  ] ;   }   template <typename Arg1>   void __trace__(const string name, Arg1&& arg1) {     cerr << name <<   :   << arg1 <<   ]   << endl;   }   template <typename Arg1, typename... Args>   void __trace__(const string names, Arg1&& arg1, Args&&... args) {     const string name = names.substr(0, names.find( , ));     cerr << name <<   :   << arg1 <<   |  ;     __trace__(names.substr(1 + (int)name.size()), args...);   }   clock_t time_p = clock();   void time_taken() {     time_p = clock() - time_p;     cerr <<  Time Taken :   << (float)(time_p) / CLOCKS_PER_SEC <<   n ;   }   const long long mod = 1e9 + 7;   const long long INF = 1e18;   const int maxn = 2e5 + 5;   vector<int> adj[maxn];   int Q[maxn];   int n;   void bfs(int s, int* d) {     for (int i = 1; i <= n; i++) {       d[i] = -1;     }     d[s] = 0;     int N = 0;     Q[N++] = s;     for (int i = 0; i < N; i++) {       int u = Q[i];       for (int v : adj[u]) {         if (d[v] == -1) {           d[v] = d[u] + 1;           Q[N++] = v;         }       }     }   }   void solve() {     int m, a, b, c;     cin >> n >> m >> a >> b >> c;     for (int i = 1; i <= n; i++) {       adj[i].clear();     }     vector<long long> p(m);     for (int i = 0; i < m; i++) cin >> p[i];     sort(p.begin(), p.end());     for (int i = 1; i <= m - 1; i++) p[i] += p[i - 1];     for (int _ = 0; _ < m; _++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     int da[n + 1], db[n + 1], dc[n + 1];     bfs(a, da);     bfs(b, db);     bfs(c, dc);     if (a == b) {       int foo = dc[a];       if (foo) {         cout << p[foo - 1] <<   n ;       } else {         cout << 0 <<   n ;       }       return;     }     if (b == c) {       int foo = da[b];       if (foo) {         cout << p[foo - 1] <<   n ;       } else {         cout << 0 <<   n ;       }       return;     }     if (c == a) {       int foo = da[b];       if (foo) {         cout << 2 * p[foo - 1] <<   n ;       } else {         cout << 0 <<   n ;       }       return;     }     long long ans = INF;     for (int i = 1; i <= n; i++) {       long long cur = 0;       int cnt = 0;       long long foo = 0;       if (db[i]) {         foo = p[db[i] - 1];         cur += 2 * p[db[i] - 1];       }       int tot = da[i] + db[i] + dc[i] - 1;       if (tot < m)         cur += p[tot] - foo;       else         continue;       ans = min(ans, cur);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cout.precision(12);     cout << fixed;     int t;     cin >> t;     while (t--) {       solve();     }     time_taken();     return 0;   }   