#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( Ofast )   #pragma GCC optimize( O3 )   const long long inf = 1e17;   void bfs(int a, vector<vector<int> > &g, vector<int> &da) {     int n = g.size();     queue<int> q;     q.push(a);     vector<bool> u(n, false);     u[a] = true;     da[a] = 0;     while (!q.empty()) {       int v = q.front();       q.pop();       for (int i = 0; i < g[v].size(); i++) {         int x = g[v][i];         if (!u[x]) {           u[x] = true;           da[x] = da[v] + 1;           q.push(x);         }       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int q;     cin >> q;     while (q--) {       int n, m, a, b, c;       cin >> n >> m >> a >> b >> c;       a--;       b--;       c--;       vector<vector<int> > g(n, vector<int>(0));       vector<long long> cost(m);       for (int i = 0; i < m; i++) cin >> cost[i];       sort(cost.begin(), cost.end());       for (int i = 1; i < m; i++) cost[i] += cost[i - 1];       vector<int> da(n, 0), db(n, 0), dc(n, 0);       for (int i = 0; i < m; i++) {         int fr, to;         cin >> fr >> to;         fr--;         to--;         g[fr].push_back(to);         g[to].push_back(fr);       }       bfs(a, g, da);       bfs(b, g, db);       bfs(c, g, dc);       long long ans = inf;       for (int i = 0; i < n; i++) {         if (da[i] + db[i] + dc[i] - 1 > m - 1) continue;         long long cur = 0;         if (da[i] + db[i] + dc[i] != 0) cur += cost[da[i] + db[i] + dc[i] - 1];         if (db[i] > 0) cur += cost[db[i] - 1];         ans = min(ans, cur);       }       cout << ans <<   n ;     }     return 0;   }   