////#pragma GCC optimzie(2)
//#include<iostream>
//#include<iomanip>
//#include<cstring>
//#include<string>
//#include<vector>
//#include<algorithm>
//#include<numeric>
//#include<chrono>
//#include <ctime>
//#include <ratio>
//#include<cmath>
//#include<queue>
//#include<stack>
//#include<map>
//#include<set>
//#include<iterator>
//#include<list>
//#include<forward_list>
//#include<bitset>
//#include<cassert>
//#include<unordered_map>
//#include<unordered_set>
//#define mp(a,b) make_pair(a,b)
//#define time chrono::steady_clock::now()
//#define diff(st,ed) chrono::duration_cast<chrono::duration<double>>(ed-st)
//#define v2(n,m) vector<vector<int>> (n,vector<int>(m))
//#define v1(n) vector<int>(n)
//#define pi acos(-1)
//using namespace std;
//typedef long long ll;
//typedef unsigned long long ull;
//typedef long double ldb;
//typedef double db;
//typedef pair<int,int> pii;
//typedef pair<long long,long long> pll;
//typedef priority_queue<int,vector<int>> pq;
//const int maxn = 2e3+7;
//ll a[maxn][maxn];
//int main()
//{
//    ios::sync_with_stdio(false);
//    cin.tie(0),cout.tie(0);
//    int n,m,k,q;
//    cin>>n>>m>>k>>q;
//    memset(a,0,sizeof(a));
//    while(k--) {
//        int x1,x2,y1,y2;
//        cin>>x1>>y1>>x2>>y2;
//        int c=1;
//        a[x1][y1]+=c;
//        a[x2+1][y1]-=c;
//        a[x1][y2+1]-=c;
//        a[x2+1][y2+1]+=c;
//    }
////    for(int i=1;i<=n;i++) {
////        for(int j=1;j<=m;j++) {
////            cout<<a[i][j]<<' ';
////        }
////        cout<<'\n';
////    }
////    cout<<"------"<<'\n';
//    for(int i=1;i<=n;i++) {
//        for(int j=1;j<=m;j++) {
//            a[i][j]=a[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1];
//        }
//    }
//    for(int i=1;i<=n;i++) {
//        for(int j=1;j<=m;j++) {
//            a[i][j]=a[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1];
//        }
//    }
//    while(q--) {
//        int x1,x2,y1,y2;
//        cin>>x1>>y1>>x2>>y2;
//        cout<<a[x2][y2]+a[x1-1][y1-1]-a[x2][y1-1]-a[x1-1][y2]<<'\n';
//    }
//    return 0;
//}

#include<iostream>
#include<iomanip>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<chrono>
#include <ctime>
#include <ratio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#include<list>
#include<forward_list>
#include<bitset>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#define mp(a,b) make_pair(a,b)
#define time chrono::steady_clock::now()
#define diff(st,ed) chrono::duration_cast<chrono::duration<double>>(ed-st);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
const int maxn=2e5+7;
ll inf = 0x3f3f3f3f;
int mod = 998244353;

int head[maxn],cnt=0;
struct Edge{
    int u,v,val,next;
}edge[maxn<<2];
void add_edge(int u,int v,int val)
{
    edge[cnt].u = u;
    edge[cnt].v = v;
    edge[cnt].val = val;
    edge[cnt].next = head[u];
    head[u] = cnt++;
}

void dij(int root,vector<ll>& dis,vector<bool> vis) {
    fill(vis.begin(),vis.end(),0);
    fill(dis.begin(),dis.end(),inf);
    priority_queue<pll,vector<pll>,greater<pll>> que;
    dis[root]=0;
    que.push(mp(dis[root],root));
    while(!que.empty()) {
        pll p = que.top();
        que.pop();
        int u = p.second;
        if(vis[u]) continue;
        vis[u] = true;
        for(int i=head[u];i!=-1;i=edge[i].next) {
            int v = edge[i].v;
            int val = edge[i].val;
            if(dis[v]>dis[u]+val) {
                dis[v]=dis[u]+val;
                que.push(mp(dis[v],v));
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t;
    cin>>t;
    while(t--) {
        int n,m,a,b,c;
        cin>>n>>m>>a>>b>>c;
        cnt = 0;
        fill(head,head+n+1,-1);
        vector<int> p(m);
        vector<ll> dis1(n+1),dis2(n+1),dis3(n+1);
        vector<bool> vis(n+1);
        for(auto &it:p)
            cin>>it;
        for(int i=0;i<m;i++) {
            int u,v;
            cin>>u>>v;
            add_edge(u,v,1);
            add_edge(v,u,1);
        }
        sort(p.begin(),p.end());
        int sum=0;
        dij(a,dis1,vis);
        dij(b,dis2,vis);
        dij(c,dis3,vis);
        sum=dis1[b]+dis3[b];
        fill(vis.begin(),vis.end(),0);
        int res = 0;
        ll ans = 0;
        for(int i=0;i<m;i++) {
            int u,v,id;
            id = 2*i;
            u = edge[id].u;
            v = edge[id].v;
            if(dis1[u]+dis2[v]+1==dis1[b]||dis1[v]+dis2[u]+1==dis1[b]) {
                if(dis3[u]+dis2[v]+1==dis3[b]||dis3[v]+dis2[u]+1==dis3[b]) {
                    assert(res<m);
                    ans+=p[res];
                    ans+=p[res++];
                    sum-=2;
                }
            }
        }
//        cout<<res<<' '<<sum<<' '<<ans<<'\n';
        while(sum>0) {
//            cerr<<p[res]<<'\n';
            assert(res<m);
            sum--;
            ans+=p[res++];
        }
        cout<<ans<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int>pii;
const int MAXN =2e5+50;
ll const MOD=1e9+7;
int n,m;
int arr[MAXN];
int vis[MAXN];
ll sum[MAXN];
vector<int>vec[MAXN];
int dp[3][MAXN];
void Dijkstra(int first,int * d)
{
    memset(vis,0,sizeof(vis));
    queue<int>que;
    que.push(first);
    d[first] = 0;
    vis[first]=1;
    while(!que.empty())
    {
        int u = que.front() ; que.pop();
        for(int v:vec[u])
        {
            if(vis[v])continue;
            vis[v]=1;
            d[v] = d[u] + 1;
            que.push(v);
        }
    }
}
int main(){
    int _;cin>>_;
    while(_--){
        int na,nb,nc;
        cin>>n>>m>>na>>nb>>nc;
        for (int i = 1; i <= m; ++i) {
            scanf("%d",&arr[i]);
        }
        sort(arr+1,arr+m+1);
        for (int i = 1; i <= m; ++i) {
            sum[i]=sum[i-1]+arr[i];
        }
        for (int i = 0; i < m; ++i) {
            int a,b;scanf("%d%d",&a,&b);
            vec[a].push_back(b);
            vec[b].push_back(a);
        }
        Dijkstra(na,dp[0]);
        Dijkstra(nb,dp[1]);
        Dijkstra(nc,dp[2]);
//        for (int i = 1; i <= 3; ++i) {
//            cout << dp[2][i] << " ";
//        }

        ll ans=1e18;
        for (int i = 1; i <= n; ++i) {
            int la=dp[1][i];
            int lb=dp[0][i];
            int lc=dp[2][i];
            ll a=sum[la]*2;
            ll b=sum[min(lb+la,m)]-sum[la];
            ll c = sum[min(lb+la+lc,m)]-sum[min(lb+la,m)];
            if(lb+lc+la>m)continue;
            ans=min(a+b+c,ans);
        }
        cout << ans << endl;
    }
}

/*

2
7 9 1 5 7
2 10 4 8 5 6 7 3 3
1 2
1 3
1 4
3 2
3 5
4 2
5 6
1 7
6 7
 * */


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int>pii;
const int MAXN =2e5+50;
ll const MOD=1e9+7;
int n,m;
int arr[MAXN];
int vis[MAXN];
ll sum[MAXN];
vector<int>vec[MAXN];
int dp[3][MAXN];
void Dijkstra(int first,int * d)
{
    memset(vis,0,sizeof(vis));
    queue<int>que;
    que.push(first);
    d[first] = 0;
    vis[first]=1;
    while(!que.empty())
    {
        int u = que.front() ; que.pop();
        for(int v:vec[u])
        {
            if(vis[v])continue;
            vis[v]=1;
            d[v] = d[u] + 1;
            que.push(v);
        }
    }
}
int main(){
    int _;cin>>_;
    while(_--){
        int na,nb,nc;
        cin>>n>>m>>na>>nb>>nc;
        for (int i = 1; i <= m; ++i) {
            scanf("%d",&arr[i]);
        }
        sort(arr+1,arr+m+1);
        for (int i = 1; i <= m; ++i) {
            sum[i]=sum[i-1]+arr[i];
        }
        for (int i = m+1; i <= 2*m; ++i) {
            sum[i]=sum[i-1]+1e9;
        }
        for (int i = 0; i < m; ++i) {
            int a,b;scanf("%d%d",&a,&b);
            vec[a].push_back(b);
            vec[b].push_back(a);
        }
        Dijkstra(na,dp[0]);
        Dijkstra(nb,dp[1]);
        Dijkstra(nc,dp[2]);
//        for (int i = 1; i <= 3; ++i) {
//            cout << dp[2][i] << " ";
//        }

        ll ans=1e18;
        for (int i = 1; i <= n; ++i) {
            int la=dp[1][i];
            int lb=dp[0][i];
            int lc=dp[2][i];
            ll a=sum[la]*2;
            ll b=sum[lb+la]-sum[la];
            ll c = sum[lb+la+lc]-sum[lb+la];
            ans=min(a+b+c,ans);
        }
        cout << ans << endl;
    }
}

/*

2
7 9 1 5 7
2 10 4 8 5 6 7 3 3
1 2
1 3
1 4
3 2
3 5
4 2
5 6
1 7
6 7
 * */


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int>pii;
const int MAXN =2e5+50;
ll const MOD=1e9+7;
int n,m;
int arr[MAXN];
int vis[MAXN];
ll sum[MAXN];
vector<int>vec[MAXN];
int dp[3][MAXN];
void Dijkstra(int first,int * d)
{
    memset(vis,0,sizeof(int)*(n+10));
    queue<int>que;
    que.push(first);
    d[first] = 0;
    vis[first]=1;
    while(!que.empty())
    {
        int u = que.front() ; que.pop();
        for(int v:vec[u])
        {
            if(vis[v])continue;
            vis[v]=1;
            d[v] = d[u] + 1;
            que.push(v);
        }
    }
}
int main(){
    int _;cin>>_;
    while(_--){
        int na,nb,nc;
        cin>>n>>m>>na>>nb>>nc;
        for (int i = 1; i <= m; ++i) {
            scanf("%d",&arr[i]);
        }
        sort(arr+1,arr+m+1);
        for (int i = 1; i <= m; ++i) {
            sum[i]=sum[i-1]+arr[i];
        }
        for (int i = m+1; i <= max(2*m,n*2); ++i) {
            sum[i]=sum[i-1]+1e9;
        }
        for (int i = 0; i < m; ++i) {
            int a,b;scanf("%d%d",&a,&b);
            vec[a].push_back(b);
            vec[b].push_back(a);
        }
        Dijkstra(na,dp[0]);
        Dijkstra(nb,dp[1]);
        Dijkstra(nc,dp[2]);
//        for (int i = 1; i <= 3; ++i) {
//            cout << dp[2][i] << " ";
//        }

        ll ans=1e18;
        for (int i = 1; i <= n; ++i) {
            int la=dp[1][i];
            int lb=dp[0][i];
            int lc=dp[2][i];
            ll a=sum[la];
            ll b=sum[lb+la+lc];
            ans=min(a+b,ans);
        }
        cout << ans << endl;
    }
}

/*

2
7 9 1 5 7
2 10 4 8 5 6 7 3 3
1 2
1 3
1 4
3 2
3 5
4 2
5 6
1 7
6 7
 * */


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int>pii;
const int MAXN =2e5+50;
ll const MOD=1e9+7;
int n,m;
int arr[MAXN];
int vis[MAXN];
ll sum[MAXN];
vector<int>vec[MAXN];
int dp[3][MAXN];
void Dijkstra(int first,int * d)
{
    memset(vis,0,sizeof(vis));
    queue<int>que;
    que.push(first);
    d[first] = 0;
    vis[first]=1;
    while(!que.empty())
    {
        int u = que.front() ; que.pop();
        for(int v:vec[u])
        {
            if(vis[v])continue;
            vis[v]=1;
            d[v] = d[u] + 1;
            que.push(v);
        }
    }
}
int main(){
    int _;cin>>_;
    while(_--){
        int na,nb,nc;
        cin>>n>>m>>na>>nb>>nc;
        for (int i = 1; i <= m; ++i) {
            scanf("%d",&arr[i]);
        }
        sort(arr+1,arr+m+1);
        for (int i = 1; i <= m; ++i) {
            sum[i]=sum[i-1]+arr[i];
        }
        for (int i = 0; i < m; ++i) {
            int a,b;scanf("%d%d",&a,&b);
            vec[a].push_back(b);
            vec[b].push_back(a);
        }
        Dijkstra(na,dp[0]);
        Dijkstra(nb,dp[1]);
        Dijkstra(nc,dp[2]);
//        for (int i = 1; i <= 3; ++i) {
//            cout << dp[2][i] << " ";
//        }

        ll ans=1e18;
        for (int i = 1; i <= n; ++i) {
            int la=dp[1][i];
            int lb=dp[0][i];
            int lc=dp[2][i];
            ll a=sum[la]*2;
            ll b=sum[min(lb+la,m)]-sum[la];
            ll c = sum[min(lb+la+lc,m)]-sum[min(lb+la,m)];
            if(lb+lc>m)continue;
            ans=min(a+b+c,ans);
        }
        cout << ans << endl;
    }
}

/*

2
7 9 1 5 7
2 10 4 8 5 6 7 3 3
1 2
1 3
1 4
3 2
3 5
4 2
5 6
1 7
6 7
 * */


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int>pii;
const int MAXN =2e5+50;
ll const MOD=1e9+7;
int n,m;
int arr[MAXN];
int vis[MAXN];
ll sum[MAXN];
vector<int>vec[MAXN];
int dp[3][MAXN];
void Dijkstra(int first,int * d)
{
    memset(vis,0,sizeof(int)*(n+10));
    queue<int>que;
    que.push(first);
    d[first] = 0;
    vis[first]=1;
    while(!que.empty())
    {
        int u = que.front() ; que.pop();
        for(int v:vec[u])
        {
            if(vis[v])continue;
            vis[v]=1;
            d[v] = d[u] + 1;
            que.push(v);
        }
    }
}
int main(){
    int _;cin>>_;
    while(_--){
        int na,nb,nc;
        cin>>n>>m>>na>>nb>>nc;
        for (int i = 1; i <= m; ++i) {
            scanf("%d",&arr[i]);
        }
        sort(arr+1,arr+m+1);
        for (int i = 1; i <= m; ++i) {
            sum[i]=sum[i-1]+arr[i];
        }
        for (int i = m+1; i <= max(2*m,n*2); ++i) {
            sum[i]=sum[i-1]+1e9;
        }
        for (int i = 0; i < m; ++i) {
            int a,b;scanf("%d%d",&a,&b);
            vec[a].push_back(b);
            vec[b].push_back(a);
        }
        Dijkstra(na,dp[0]);
        Dijkstra(nb,dp[1]);
        Dijkstra(nc,dp[2]);
//        for (int i = 1; i <= 3; ++i) {
//            cout << dp[2][i] << " ";
//        }

        ll ans=1e18;
        for (int i = 1; i <= n; ++i) {
            int la=dp[1][i];
            int lb=dp[0][i];
            int lc=dp[2][i];
            ll a=sum[la];
            ll b=sum[lb+la+lc];
            if(la+lb+lc>m)continue;
            ans=min(a+b,ans);
        }
        cout << ans << endl;
    }
}

/*

2
7 9 1 5 7
2 10 4 8 5 6 7 3 3
1 2
1 3
1 4
3 2
3 5
4 2
5 6
1 7
6 7
 * */


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int>pii;
const int MAXN =2e5+50;
ll const MOD=1e9+7;
int n,m;
int arr[MAXN];
int vis[MAXN];
ll sum[MAXN];
vector<int>vec[MAXN];
int dp[3][MAXN];
void Dijkstra(int first,int * d)
{
    memset(vis,0,sizeof(vis));
    queue<int>que;
    que.push(first);
    d[first] = 0;
    vis[first]=1;
    while(!que.empty())
    {
        int u = que.front() ; que.pop();
        for(int v:vec[u])
        {
            if(vis[v])continue;
            vis[v]=1;
            d[v] = d[u] + 1;
            que.push(v);
        }
    }
}
int main(){
    int _;cin>>_;
    while(_--){
        int na,nb,nc;
        cin>>n>>m>>na>>nb>>nc;
        for (int i = 1; i <= m; ++i) {
            scanf("%d",&arr[i]);
        }
        sort(arr+1,arr+m+1);
        for (int i = 1; i <= m; ++i) {
            sum[i]=sum[i-1]+arr[i];
        }
        for (int i = m+1; i <= 2*m; ++i) {
            sum[i]=sum[i-1]+1e9;
        }
        for (int i = 0; i < m; ++i) {
            int a,b;scanf("%d%d",&a,&b);
            vec[a].push_back(b);
            vec[b].push_back(a);
        }
        Dijkstra(na,dp[0]);
        Dijkstra(nb,dp[1]);
        Dijkstra(nc,dp[2]);
//        for (int i = 1; i <= 3; ++i) {
//            cout << dp[2][i] << " ";
//        }

        ll ans=1e18;
        for (int i = 1; i <= n; ++i) {
            int la=dp[1][i];
            int lb=dp[0][i];
            int lc=dp[2][i];
            ll a=sum[la];
            ll b=sum[lb+la+lc];
            ans=min(a+b,ans);
        }
        cout << ans << endl;
    }
}

/*

2
7 9 1 5 7
2 10 4 8 5 6 7 3 3
1 2
1 3
1 4
3 2
3 5
4 2
5 6
1 7
6 7
 * */


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int>pii;
const int MAXN =2e5+50;
ll const MOD=1e9+7;
int n,m;
int arr[MAXN];
int vis[MAXN];
ll sum[MAXN];
vector<int>vec[MAXN];
int dp[3][MAXN];
void Dijkstra(int first,int * d)
{
    memset(vis,0,sizeof(int)*(n+10));
    memset(d,0,sizeof(int)*(n+10));
    queue<int>que;
    que.push(first);
    d[first] = 0;
    vis[first]=1;
    while(!que.empty())
    {
        int u = que.front(); que.pop();
        for(int v:vec[u])
        {
            if(vis[v])continue;
            vis[v]=1;
            d[v] = d[u] + 1;
            que.push(v);
        }
    }
}
int main(){
    int _;cin>>_;
    while(_--){
        int na,nb,nc;
        cin>>n>>m>>na>>nb>>nc;
        for (int i = 1; i <= n; ++i) {
            vec[i].clear();
        }
        for (int i = 1; i <= m; ++i) {
            scanf("%d",&arr[i]);
        }
        sort(arr+1,arr+m+1);
        for (int i = 1; i <= m; ++i) {
            sum[i]=sum[i-1]+arr[i];
        }
        for (int i = 0; i < m; ++i) {
            int a,b;scanf("%d%d",&a,&b);
            vec[a].push_back(b);
            vec[b].push_back(a);
        }
        Dijkstra(na,dp[0]);
        Dijkstra(nb,dp[1]);
        Dijkstra(nc,dp[2]);
//        for (int i = 1; i <= 3; ++i) {
//            cout << dp[2][i] << " ";
//        }

        ll ans=1e18;
        for (int i = 1; i <= n; ++i) {
            int la=dp[1][i];
            int lb=dp[0][i];
            int lc=dp[2][i];
            ll a=sum[la];
            ll b=sum[lb+la+lc];
            if(la+lb+lc>m)continue;
            ans=min(a+b,ans);
        }
        cout << ans << endl;
    }
}

/*

2
3 2 3 3 1
1 2
3 2
2 1
 * */


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
void before()
{
    // to be used to clear for each test case
    loop(i,1,e)
    g[i].clear();;
}

void bfs(int x , vi &d)
{
    //memset(par,0,sizeof(par));
    vi v(e,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        //ans++;
        for(auto c : g[up])
        {
            if(!v[c])
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
void solve()
{
    before();
    int n , m , a , b , c;
    cin>>n>>m>>a>>b>>c;
    vl p(m);
    for(ll &x:p)
    cin>>x;
    sort(all(p));
    vl pre(m+1);
    loop(i,0,m)
    pre[i+1]=pre[i]+p[i];
    loop(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    vi x(e),y(e),z(e);
    bfs(a,x);
    bfs(b,y);
    bfs(c,z);
   // show(p,m);
    //show(pre,m);
    ll ans = INF;
    for(int i = 1 ; i<=n ; i++)
    {
        if(x[i]+y[i]+z[i]>m)
        continue;
        ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        //seee(ans,y[i]-1,x[i]+y[i]+z[i]-1);
        //se(ans);
    }
    cout<<ans<<endl;
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
int n , m ;
void bfs(int x , vl &d)
{
    queue<int>q;
    q.push(x);
    d[x]=0;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        for(auto c : g[up])
        {
            if(d[c]==INF)
            {
                d[c] = d[up]+1;
                q.push(c);
            }
        }
    }
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    {
        //sig
        int  a , b , c;
        cin>>n>>m>>a>>b>>c;
        vl p(m);
        scan(p,m);
        loop(i,1,n+1)
            g[i].clear();
        sort(all(p));
        vl pre(m+1);
        loop(i,0,m)
        pre[i+1]=pre[i]+p[i];
        loop(i,0,m)
        {
            int x,y;
            cin>>x>>y;
            g[x].pb(y);
            g[y].pb(x);
        }
        vl x(n+1,INF),y(n+1,INF),z(n+1,INF);
        bfs(a,x);
        bfs(b,y);
        bfs(c,z);
        ll ans = INF;
        for(int i = 1 ; i<=n ; i++)
        {
            if(x[i]+y[i]+z[i]>m)
            continue;
            ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        }
        cout<<ans<<endl;
    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
void bfs(int x , vi &d)
{
    //memset(par,0,sizeof(par));
    vi v(e,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        //ans++;
        for(auto c : g[up])
        {
            if(!v[c])
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    {
        int n , m , a , b , c;
        cin>>n>>m>>a>>b>>c;
        vl p(m);
        loop(i,1,n+1)
        g[i].clear();
        for(int i = 0 ; i<m ; i++)
        cin>>p[i];
        sort(all(p));
        vl pre(m+1);
        loop(i,0,m)
        pre[i+1]=pre[i]+p[i];
        loop(i,0,m)
        {
            int x,y;
            cin>>x>>y;
            g[x].pb(y);
            g[y].pb(x);
        }
        vi x(e),y(e),z(e);
        bfs(a,x);
        bfs(b,y);
        bfs(c,z);
       // show(p,m);
        //show(pre,m);
        ll ans = INF;
        for(int i = 1 ; i<=n ; i++)
        {
            if(x[i]+y[i]+z[i]>m)
            continue;
            ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
            //seee(ans,y[i]-1,x[i]+y[i]+z[i]-1);
            //se(ans);
        }
        cout<<ans<<endl;
    }
    //solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
int n , m ;
void bfs(int x , vl &d)
{
    vi v(n+1,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        for(auto c : g[up])
        {
            if(v[c]==0)
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    {
        //sig
        int  a , b , c;
        cin>>n>>m>>a>>b>>c;
        vl p(m);
        scan(p,m);
        loop(i,1,n+1)
            g[i].clear();
        sort(all(p));
        vl pre(m+1);
        loop(i,0,m)
        pre[i+1]=pre[i]+p[i];
        loop(i,0,m)
        {
            int x,y;
            cin>>x>>y;
            g[x].pb(y);
            g[y].pb(x);
        }
        vl x(n+1),y(n+1),z(n+1);
        bfs(a,x);
        bfs(b,y);
        bfs(c,z);
        ll ans = INF;
        for(int i = 1 ; i<=n ; i++)
        {
            if(x[i]+y[i]+z[i]>m)
            continue;
            ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        }
        cout<<ans<<endl;
    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
template<typename T>void show(T &a , int n )
{
    loop(i,0,n)
        cout<<a[i]<<" ";
    cout<<endl;
}
vi g[e];
void before()
{
    // to be used to clear for each test case
    loop(i,0,e)
    g[i].clear();;
}

void bfs(int x , vi &d)
{
    //memset(par,0,sizeof(par));
    vi v(e,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        //ans++;
        for(auto c : g[up])
        {
            if(!v[c])
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
void solve()
{
    before();
    int n , m , a , b , c;
    cin>>n>>m>>a>>b>>c;
    vl p(m);
    for(ll &x:p)
    cin>>x;
    sort(all(p));
    vl pre(m+1);
    loop(i,0,m)
    pre[i+1]=pre[i]+p[i];
    loop(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    vi x(e),y(e),z(e);
    bfs(a,x);
    bfs(b,y);
    bfs(c,z);
    show(p,m);
    show(pre,m);
    ll ans = INF;
    for(int i = 1 ; i<=n ; i++)
    {
        if(x[i]+y[i]+z[i]>m)
        continue;
        ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        //seee(ans,y[i]-1,x[i]+y[i]+z[i]-1);
        //se(ans);
    }
    cout<<ans<<endl;
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
int n , m ;
void bfs(int x , vl &d)
{
    vi v(n+1,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        for(auto c : g[up])
        {
            if(v[c]==0)
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    {
        loop(i,0,e)
            g[i].clear();
        int  a , b , c;
        cin>>n>>m>>a>>b>>c;
        vl p(m);
        scan(p,m);
        sort(all(p));
        vl pre(m+1);
        loop(i,0,m)
        pre[i+1]=pre[i]+p[i];
        loop(i,0,m)
        {
            int x,y;
            cin>>x>>y;
            g[x].pb(y);
            g[y].pb(x);
        }
        vl x(n+1),y(n+1),z(n+1);
        bfs(a,x);
        bfs(b,y);
        bfs(c,z);
        ll ans = INF;
        for(int i = 1 ; i<=n ; i++)
        {
            if(x[i]+y[i]+z[i]>m)
            continue;
            ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        }
        cout<<ans<<endl;
    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
int n , m ;
void bfs(int x , vl &d)
{
    vi v(n+1,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    d[x]=0;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        for(auto c : g[up])
        {
            if(v[c]==0)
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    {
        //sig
        int  a , b , c;
        cin>>n>>m>>a>>b>>c;
        vl p(m);
        scan(p,m);
        loop(i,0,n)
            g[i].clear();
        sort(all(p));
        vl pre(m+1);
        loop(i,0,m)
        pre[i+1]=pre[i]+p[i];
        loop(i,0,m)
        {
            int x,y;
            cin>>x>>y;
            g[x].pb(y);
            g[y].pb(x);
        }
        vl x(n+1),y(n+1),z(n+1);
        bfs(a,x);
        bfs(b,y);
        bfs(c,z);
        ll ans = INF;
        for(int i = 1 ; i<=n ; i++)
        {
            if(x[i]+y[i]+z[i]>m)
            continue;
            ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        }
        cout<<ans<<endl;
    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
void before()
{
    // to be used to clear for each test case
    loop(i,1,e)
    g[i].clear();;
}

void bfs(int x , vi &d)
{
    //memset(par,0,sizeof(par));
    vi v(e,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        //ans++;
        for(auto c : g[up])
        {
            if(!v[c])
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
void solve()
{
    before();
    int n , m , a , b , c;
    cin>>n>>m>>a>>b>>c;
    vl p(m);
    for(int i = 0 ; i<m ; i++)
    cin>>p[i];
    sort(all(p));
    vl pre(m+1);
    loop(i,0,m)
    pre[i+1]=pre[i]+p[i];
    loop(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    vi x(e),y(e),z(e);
    bfs(a,x);
    bfs(b,y);
    bfs(c,z);
   // show(p,m);
    //show(pre,m);
    ll ans = INF;
    for(int i = 1 ; i<=n ; i++)
    {
        if(x[i]+y[i]+z[i]>m)
        continue;
        ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        //seee(ans,y[i]-1,x[i]+y[i]+z[i]-1);
        //se(ans);
    }
    cout<<ans<<endl;
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
int n , m ;
void bfs(int x , vl &d)
{
    vi v(n+1,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        for(auto c : g[up])
        {
            if(v[c]==0)
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    {
        //sig
        int  a , b , c;
        cin>>n>>m>>a>>b>>c;
        vl p(m);
        scan(p,m);
        sort(all(p));
        vl pre(m+1);
        loop(i,0,m)
        pre[i+1]=pre[i]+p[i];
        loop(i,0,m)
        {
            int x,y;
            cin>>x>>y;
            g[x].pb(y);
            g[y].pb(x);
        }
        vl x(n+1),y(n+1),z(n+1);
        bfs(a,x);
        bfs(b,y);
        bfs(c,z);
        ll ans = INF;
        for(int i = 1 ; i<=n ; i++)
        {
            if(x[i]+y[i]+z[i]>m)
            continue;
            ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        }
        cout<<ans<<endl;
    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
template<typename T>void show(T &a , int n )
{
    loop(i,0,n)
        cout<<a[i]<<" ";
    cout<<endl;
}
vi g[e];
void before()
{
    // to be used to clear for each test case
    loop(i,0,e)
    g[i].clear();;
}

void bfs(int x , vi &d)
{
    //memset(par,0,sizeof(par));
    vi v(e,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        //ans++;
        for(auto c : g[up])
        {
            if(!v[c])
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
void solve()
{
    before();
    int n , m , a , b , c;
    cin>>n>>m>>a>>b>>c;
    vl p(m);
    for(ll &x:p)
    cin>>x;
    sort(all(p));
    vl pre(m+1);
    loop(i,0,m)
    pre[i+1]=pre[i]+p[i];
    loop(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    vi x(e),y(e),z(e);
    bfs(a,x);
    bfs(b,y);
    bfs(c,z);
   // show(p,m);
    //show(pre,m);
    ll ans = INF;
    for(int i = 1 ; i<=n ; i++)
    {
        if(x[i]+y[i]+z[i]>m)
        continue;
        ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        //seee(ans,y[i]-1,x[i]+y[i]+z[i]-1);
        //se(ans);
    }
    cout<<ans<<endl;
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
int n , m ;
void bfs(int x , vl &d)
{
    vi v(n+1,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        for(auto c : g[up])
        {
            if(v[c]==0)
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
           {
               //sig
               int  a , b , c;
               cin>>n>>m>>a>>b>>c;
               vl p(m);
               scan(p,m);
               loop(i,0,n)
                   g[i].clear();
               sort(all(p));
               vl pre(m+1);
               loop(i,0,m)
               pre[i+1]=pre[i]+p[i];
               loop(i,0,m)
               {
                   int x,y;
                   cin>>x>>y;
                   g[x].pb(y);
                   g[y].pb(x);
               }
               vl x(n+1),y(n+1),z(n+1);
               bfs(a,x);
               bfs(b,y);
               bfs(c,z);
               ll ans = INF;
               for(int i = 1 ; i<=n ; i++)
               {
                   if(x[i]+y[i]+z[i]>m)
                   continue;
                   ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
               }
               cout<<ans<<endl;
           }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
void bfs(int x , vi &d)
{
    //memset(par,0,sizeof(par));
    vi v(e,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        //ans++;
        for(auto c : g[up])
        {
            if(!v[c])
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
void solve()
{
    //before();
    loop(i,1,e)
    g[i].clear();;
    int n , m , a , b , c;
    cin>>n>>m>>a>>b>>c;
    vl p(m);
    for(int i = 0 ; i<m ; i++)
    cin>>p[i];
    sort(all(p));
    vl pre(m+1);
    loop(i,0,m)
    pre[i+1]=pre[i]+p[i];
    loop(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    vi x(e),y(e),z(e);
    bfs(a,x);
    bfs(b,y);
    bfs(c,z);
   // show(p,m);
    //show(pre,m);
    ll ans = INF;
    for(int i = 1 ; i<=n ; i++)
    {
        if(x[i]+y[i]+z[i]>m)
        continue;
        ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        //seee(ans,y[i]-1,x[i]+y[i]+z[i]-1);
        //se(ans);
    }
    cout<<ans<<endl;
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
void bfs(int x , vi &d, int n)
{
    //memset(par,0,sizeof(par));
    vi v(n+1,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        //ans++;
        for(auto c : g[up])
        {
            if(!v[c])
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    {
        int n , m , a , b , c;
        cin>>n>>m>>a>>b>>c;
        vl p(m);
        loop(i,1,n+1)
        g[i].clear();
        for(int i = 0 ; i<m ; i++)
        cin>>p[i];
        sort(all(p));
        vl pre(m+1);
        loop(i,0,m)
        pre[i+1]=pre[i]+p[i];
        loop(i,0,m)
        {
            int x,y;
            cin>>x>>y;
            g[x].pb(y);
            g[y].pb(x);
        }
        vi x(e),y(e),z(e);
        bfs(a,x,n);
        bfs(b,y,n);
        bfs(c,z,n);
       // show(p,m);
        //show(pre,m);
        ll ans = INF;
        for(int i = 1 ; i<=n ; i++)
        {
            if(x[i]+y[i]+z[i]>m)
            continue;
            ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
            //seee(ans,y[i]-1,x[i]+y[i]+z[i]-1);
            //se(ans);
        }
        cout<<ans<<endl;
    }
    //solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define M                  1000000007
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(int i=a;i<n;i++)
#define trav(a,x)          for(auto &a:x)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vii                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define si(x)              x.size()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);

const int e = 2*100005;
const ll INF = 1e18+5;
vi g[e];
void bfs(int x , vi &d)
{
    //memset(par,0,sizeof(par));
    vi v(e,0);
    v[x] = 1;
    queue<int>q;
    q.push(x);
    int ans = 0 ;
    while(!q.empty())
    {

        int up = q.front();
        q.pop();
        //ans++;
        for(auto c : g[up])
        {
            if(!v[c])
            {
                d[c] = d[up]+1;
                v[c] = 1;
                q.push(c);
            }
        }
    }
}
void solve()
{
    //before();

    int n , m , a , b , c;
    cin>>n>>m>>a>>b>>c;
    vl p(m);
    loop(i,1,n+1)
    g[i].clear();
    for(int i = 0 ; i<m ; i++)
    cin>>p[i];
    sort(all(p));
    vl pre(m+1);
    loop(i,0,m)
    pre[i+1]=pre[i]+p[i];
    loop(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    vi x(e),y(e),z(e);
    bfs(a,x);
    bfs(b,y);
    bfs(c,z);
   // show(p,m);
    //show(pre,m);
    ll ans = INF;
    for(int i = 1 ; i<=n ; i++)
    {
        if(x[i]+y[i]+z[i]>m)
        continue;
        ans = min(ans,2*pre[y[i]]+pre[x[i]+z[i]+y[i]]-pre[y[i]]);
        //seee(ans,y[i]-1,x[i]+y[i]+z[i]-1);
        //se(ans);
    }
    cout<<ans<<endl;
}
int main() {
	// your code goes here
	io;
	int t ;
	cin>>t;
	while(t--)
    solve();
	return 0;
}


#define ll long long
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> g;

void bfs(int s,vector<int> &v){
	v[s]=0;
	queue<int> q;
	q.push(s);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto it : g[x]){
			if(v[it]==-1){
				v[it]=v[x]+1;
				q.push(it);
			}
		}
	}
	return;
}

int main(){
	int t;cin>>t;
	while(t--){
		int n,m,a,b,c;cin>>n>>m>>a>>b>>c;
		--a;--b;--c;
		vector<int> p(m);
		for(auto &it : p)cin>>it;
		sort(p.begin(),p.end());

		vector<ll> pref(m+1);
		for(int i=1;i<=m;++i){
			pref[i]=pref[i-1]+p[i-1];
		}

		g=vector<vector<int>>(n);
		for(int i=0;i<m;++i){
			int x,y;cin>>x>>y;
			--x;--y;
			g[x].push_back(y);
			g[y].push_back(x);
		}

		vector<int> da(n,-1),db(n,-1),dc(n,-1);
		bfs(a,da);
		bfs(b,db);
		bfs(c,dc);
		ll ans=1e18;
		for(int i=0;i<n;++i){
			if(da[i]+db[i]+dc[i]>m)continue;
			ans=min(ans,pref[db[i]]+pref[da[i]+db[i]+dc[i]]);
		}
		cout<<ans<<"\n";
	}
	return 0;
}


//author-micheal corleone
//the godfather

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<ll>> g;
const int MOD = 1e9+7;
bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;

    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

void bfs(ll s,vector<int> &v)
{
	v[s]=0;
	queue<ll> q;
	q.push(s);
	while(!q.empty())
	{
		ll x=q.front();
		q.pop();
		for(auto it:g[x])
		{
			if(v[it]==-1)
			{
				v[it]=v[x]+1;
				q.push(it);
			}

		}
	}
	return;
}

int main(){
	ll T;
	cin >> T;
	while(T--){

		ll n,m,a,b,c,i,j;
		a--,b--,c--;
		vector<int> p(m);

		for(i=0;i<m;m++)
		{
			cin>>p[i];
		}
		vector<ll> pref(m+1);
		for(i=1;i<=m;i++)
		{
			pref[i]=pref[i-1]+p[i-1];
		}
	     g=vector<vector<int>>(n);
		for(i=0;i<m;i++)
		{
			ll x,y;
			cin>>x>>y;
			x--,y--;
			g[x].push_back(y);
			g[y].push_back(x);
		}
		vector<ll> da(n,-1),db(n,-1),dc(n,-1);
		bfs(a,da);
		bfs(b,db);
		bfs(c,dc);
		ll ans=1e18;
		for( i=0;i<n;++i){
			if(da[i]+db[i]+dc[i]>m)continue;
			ans=min(ans,pref[db[i]]+pref[da[i]+db[i]+dc[i]]);
		}
		cout<<ans<<endl;

	}
}


//author-micheal corleone
//the godfather

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<ll>> g;
const int MOD = 1e9+7;
bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;

    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

void bfs(ll s,vector<ll> &v)
{
	v[s]=0;
	queue<ll> q;
	q.push(s);
	while(!q.empty())
	{
		ll x=q.front();
		q.pop();
		for(auto it:g[x])
		{
			if(v[it]==-1)
			{
				v[it]=v[x]+1;
				q.push(it);
			}

		}
	}
	return;
}

int main(){
	ll T;
	cin >> T;
	while(T--){

		ll n,m,a,b,c,i,j;
		a--,b--,c--;
		vector<int> p(m);

		for(i=0;i<m;i++)
		{
			cin>>p[i];
		}
		vector<ll> pref(m+1);
		for(i=1;i<=m;i++)
		{
			pref[i]=pref[i-1]+p[i-1];
		}
	    // g=vector<vector<int>>(n);
		for(i=0;i<m;i++)
		{
			ll x,y;
			cin>>x>>y;
			x--,y--;
			g[x].push_back(y);
			g[y].push_back(x);
		}
		vector<ll> da(n,-1),db(n,-1),dc(n,-1);
		bfs(a,da);
		bfs(b,db);
		bfs(c,dc);
		ll ans=1e18;
		for( i=0;i<n;++i){
			if(da[i]+db[i]+dc[i]>m)continue;
			ans=min(ans,pref[db[i]]+pref[da[i]+db[i]+dc[i]]);
		}
		cout<<ans<<endl;

	}
}


//author-micheal corleone
//the godfather

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<ll>> g;
const int MOD = 1e9+7;
bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;

    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

void bfs(ll s,vector<int> &v)
{
	v[s]=0;
	queue<ll> q;
	q.push(s);
	while(!q.empty())
	{
		ll x=q.front();
		q.pop();
		for(auto it:g[x])
		{
			if(v[it]==-1)
			{
				v[it]=v[x]+1;
				q.push(it);
			}

		}
	}
	return;
}

int main(){
	ll T;
	cin >> T;
	while(T--){

		ll n,m,a,b,c,i,j;
		a--,b--,c--;
		vector<int> p(m);

		for(i=0;i<m;i++)
		{
			cin>>p[i];
		}
		vector<ll> pref(m+1);
		for(i=1;i<=m;i++)
		{
			pref[i]=pref[i-1]+p[i-1];
		}
	    // g=vector<vector<int>>(n);
		for(i=0;i<m;i++)
		{
			ll x,y;
			cin>>x>>y;
			x--,y--;
			g[x].push_back(y);
			g[y].push_back(x);
		}
		vector<ll> da(n,-1),db(n,-1),dc(n,-1);
		bfs(a,da);
		bfs(b,db);
		bfs(c,dc);
		ll ans=1e18;
		for( i=0;i<n;++i){
			if(da[i]+db[i]+dc[i]>m)continue;
			ans=min(ans,pref[db[i]]+pref[da[i]+db[i]+dc[i]]);
		}
		cout<<ans<<endl;

	}
}


//author-micheal corleone
//the godfather

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<ll>> g;
const int MOD = 1e9+7;
bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;

    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

void bfs(ll s,vector<ll> &v)
{
	v[s]=0;
	queue<ll> q;
	q.push(s);
	while(!q.empty())
	{
		ll x=q.front();
		q.pop();
		for(auto it:g[x])
		{
			if(v[it]==-1)
			{
				v[it]=v[x]+1;
				q.push(it);
			}

		}
	}
	return;
}

int main(){
	ll T;
	cin >> T;
	while(T--){

		ll n,m,a,b,c,i,j;
		a--,b--,c--;
		vector<int> p;

		for(i=0;i<m;i++)
		{
		    ll x;
		    cin>>x;
			p.push_back(x);
		}
		sort(p.begin(),p.end());
		vector<ll> pref(m+1);
		for(i=1;i<=m;i++)
		{
			pref[i]=pref[i-1]+p[i-1];
		}
	    // g=vector<vector<int>>(n);
		for(i=0;i<m;i++)
		{
			ll x,y;
			cin>>x>>y;
			x--,y--;
			g[x].push_back(y);
			g[y].push_back(x);
		}
		vector<ll> da(n,-1),db(n,-1),dc(n,-1);
		bfs(a,da);
		bfs(b,db);
		bfs(c,dc);
		ll ans=1e18;
		for( i=0;i<n;++i){
			if(da[i]+db[i]+dc[i]>m)continue;
			ans=min(ans,pref[db[i]]+pref[da[i]+db[i]+dc[i]]);
		}
		cout<<ans<<endl;

	}
}


//author-micheal corleone
//the godfather

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<ll>> g;
const int MOD = 1e9+7;
bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;

    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

void bfs(ll s,vector<ll> &v)
{
	v[s]=0;
	queue<ll> q;
	q.push(s);
	while(!q.empty())
	{
		ll x=q.front();
		q.pop();
		for(auto it:g[x])
		{
			if(v[it]==-1)
			{
				v[it]=v[x]+1;
				q.push(it);
			}

		}
	}
	return;
}

int main(){
	ll T;
	cin >> T;
	while(T--){

		ll n,m,a,b,c,i,j;
		a--,b--,c--;
		vector<int> p(m);

		for(i=0;i<m;m++)
		{
			cin>>p[i];
		}
		vector<ll> pref(m+1);
		for(i=1;i<=m;i++)
		{
			pref[i]=pref[i-1]+p[i-1];
		}
	    // g=vector<vector<int>>(n);
		for(i=0;i<m;i++)
		{
			ll x,y;
			cin>>x>>y;
			x--,y--;
			g[x].push_back(y);
			g[y].push_back(x);
		}
		vector<ll> da(n,-1),db(n,-1),dc(n,-1);
		bfs(a,da);
		bfs(b,db);
		bfs(c,dc);
		ll ans=1e18;
		for( i=0;i<n;++i){
			if(da[i]+db[i]+dc[i]>m)continue;
			ans=min(ans,pref[db[i]]+pref[da[i]+db[i]+dc[i]]);
		}
		cout<<ans<<endl;

	}
}


//author-micheal corleone
//the godfather

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<ll>> g;
const int MOD = 1e9+7;
bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;

    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

void bfs(ll s,vector<int> &v)
{
	v[s]=0;
	queue<ll> q;
	q.push(s);
	while(!q.empty())
	{
		ll x=q.front();
		q.pop();
		for(auto it:g[x])
		{
			if(v[it]==-1)
			{
				v[it]=v[x]+1;
				q.push(it);
			}

		}
	}
	return;
}

int main(){
	ll T;
	cin >> T;
	while(T--){

		ll n,m,a,b,c,i,j;
		a--,b--,c--;
		vector<int> p(m);

		for(i=0;i<m;m++)
		{
			cin>>p[i];
		}
		vector<ll> pref(m+1);
		for(i=1;i<=m;i++)
		{
			pref[i]=pref[i-1]+p[i-1];
		}
	    // g=vector<vector<int>>(n);
		for(i=0;i<m;i++)
		{
			ll x,y;
			cin>>x>>y;
			x--,y--;
			g[x].push_back(y);
			g[y].push_back(x);
		}
		vector<ll> da(n,-1),db(n,-1),dc(n,-1);
		bfs(a,da);
		bfs(b,db);
		bfs(c,dc);
		ll ans=1e18;
		for( i=0;i<n;++i){
			if(da[i]+db[i]+dc[i]>m)continue;
			ans=min(ans,pref[db[i]]+pref[da[i]+db[i]+dc[i]]);
		}
		cout<<ans<<endl;

	}
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

void bfs(vector<ll>* edges,ll n,ll* parent,ll x){
	queue<ll> q;
	bool visited[n];
	REP(i,0,n) visited[i] = 0;

	q.push(x);
	visited[x] = 1;
	while(q.size()){
		ll curr = q.front();
		q.pop();
		for(auto u : edges[curr]){
			if(!visited[u]){
				visited[u] = 1;
				q.push(u);
				parent[u] = curr;
			}
		}
	}
}

int main()
{
	ll t;
	cin>>t;
	while(t--){
		ll n,e,a,b,c;
		cin>>n>>e>>a>>b>>c;

		vector<ll> edges[n];
		// ll* distance = new ll[n]();

		ll arr[e];
		REP(i,0,e){
			cin>>arr[i];
		}

		REP(i,0,e){
			ll x,y;
			cin>>x>>y;
			edges[x-1].push_back(y-1);
			edges[y-1].push_back(x-1);
		}

		ll* parent1 = new ll[n];
		REP(i,0,n) parent1[i] = -1;
		parent1[a-1] = a-1;

		ll* parent2 = new ll[n];
		REP(i,0,n) parent2[i] = -1;
		parent2[b-1] = b-1;

		bfs(edges,n,parent1,a-1);
		bfs(edges,n,parent2,b-1);

		map<pair<ll,ll>,ll> um1,um2;

		ll v1 = b-1;
		while(v1 != a-1){
			um1[{v1,parent1[v1]}]++;
			um1[{parent1[v1],v1}]++;
			um2[{v1,parent1[v1]}]+=2;
			um2[{parent1[v1],v1}]+=2;
			v1 = parent1[v1];
		}

		v1 = c-1;
		while(v1 != b-1){
			um1[{v1,parent2[v1]}]++;
			um1[{parent2[v1],v1}]++;
			v1 = parent2[v1];
		}

		v1 = c-1;
		while(v1 != a-1){
			um2[{v1,parent1[v1]}]++;
			um2[{parent1[v1],v1}]++;
			v1 = parent1[v1];
		}

		map<pair<ll,ll>,ll> mp;
		vector<ll> v11,v12;

		for(auto it:um1){
			if(!mp.count({(it.first).second,(it.first).first})){
				mp[{(it.first).first,(it.first).second}] = 1;
				v11.push_back(it.second);
			}
		}
		for(auto it:um2){
			if(!mp.count({(it.first).second,(it.first).first})){
				mp[{(it.first).first,(it.first).second}] = 1;
				v12.push_back(it.second);
			}
		}

		sort(arr,arr+e);

		sort(v11.begin(),v11.end());
		reverse(v11.begin(),v11.end());
		sort(v12.begin(),v12.end());
		reverse(v12.begin(),v12.end());

		ll sum1 = 0,sum2 = 0;
		REP(i,0,v11.size()){
			sum1 += v11[i]*arr[i];
		}
		REP(i,0,v12.size()){
			sum2 += v12[i]*arr[i];
		}
		// cout<<sum1<<" "<<sum2<<endl;
		cout<<min(sum1,sum2)<<endl;
	}
	return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    #define ll long long
    #define REP(i, a, b) for (ll i = a; i < b; i++)
    #define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
    #define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
    #define INF (ll)1e18 + 100
    #define endl "\n"
    #define p0(a) cout << a << " "
    #define p1(a) cout << a << endl
    #define p2(a, b) cout << a << " " << b << endl
    #define p3(a, b, c) cout << a << " " << b << " " << c << endl
    #define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
    #define MAX 1e6
    /*SOME BITMASK KNOWLEDGE
    1)x & (x - 1):sets the last one bit of x to zero
    power of two exactly when x & (x − 1) = 0.
    2)x & -x:sets all the one bits to zero, except last one bit
    3)x | (x - 1):inverts all the bits after the last one bit*/
    #define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
    #define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
    typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
    //1. order_of_key(k) : number of elements strictly lesser than k
    //2. find_by_order(k) : k-th element in the set

    void bfs(vector<ll>* edges,ll n,ll* distance,ll x){
    	queue<ll> q;
    	bool visited[n];
    	REP(i,0,n) visited[i] = 0;

    	q.push(x);
    	visited[x] = 1;
    	while(q.size()){
    		ll curr = q.front();
    		q.pop();
    		for(auto u : edges[curr]){
    			if(!visited[u]){
    				visited[u] = 1;
    				distance[u] = distance[curr] + 1;
    				q.push(u);
    			}
    		}
    	}
    }

    int main()
    {
    	ll t;
    	cin>>t;
    	while(t--){
    		ll n,m,a,b,c;
    		cin>>n>>m>>a>>b>>c;
    		a--; b--; c--;
    		ll arr[m];
    		REP(i,0,m) cin>>arr[i];
    		vector<ll> edges[n];
    		REP(i,0,m){
    			ll x,y;
    			cin>>x>>y;
    			edges[x-1].push_back(y-1);
    			edges[y-1].push_back(x-1);
    		}
    		sort(arr,arr+m);
    		ll pref[m+1] = {0};
    		REP(i,1,m+1){
    			pref[i] = pref[i-1] + arr[i-1];
    		}
    		ll* distance1 = new ll[n];
    		ll* distance2 = new ll[n];
    		ll* distance3 = new ll[n];
    		bfs(edges,n,distance1,a);
    		bfs(edges,n,distance2,b);
    		bfs(edges,n,distance3,c);

    		// REP(i,0,n) cout<<distance1[i]<<" ";
    		// cout<<endl;
    		// REP(i,0,n) cout<<distance2[i]<<" ";
    		// cout<<endl;
    		// REP(i,0,n) cout<<distance3[i]<<" ";
    		// cout<<endl;
    		// REP(i,1,m) cout<<pref[i]<<" ";
    		// cout<<endl;

    		ll mini = 1e9;
    		REP(i,0,n){
    			if(distance1[i] + distance2[i] + distance3[i] > m){
    				continue;
    			}
    			mini = min(mini,pref[distance2[i]] + pref[distance1[i] + distance2[i] + distance3[i]]);
    		}
    		cout<<mini<<endl;
    	}
    	return 0;
    }


#include <bits/stdc++.h>

using namespace std;

const int INF = 1e9;

vector<vector<int>> g;

void bfs(int s, vector<int> &d) {
	d[s] = 0;
	queue<int> q;
	q.push(s);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (auto to : g[v]) {
			if (d[to] == INF) {
				d[to] = d[v] + 1;
				q.push(to);
			}
		}
	}
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n, m, a, b, c;
		cin >> n >> m >> a >> b >> c;
		--a, --b, --c;

		vector<int> p(m);
		for (auto &it : p) cin >> it;
		sort(p.begin(), p.end());
		vector<long long> pref(m + 1);
		for (int i = 0; i < m; ++i) {
			pref[i + 1] = pref[i] + p[i];
		}

		g = vector<vector<int>>(n);
		for (int i = 0; i < m; ++i) {
			int x, y;
			cin >> x >> y;
			--x, --y;
			g[x].push_back(y);
			g[y].push_back(x);
		}

		vector<int> da(n, INF), db(n, INF), dc(n, INF);
		bfs(a, da);
		bfs(b, db);
		bfs(c, dc);

		long long ans = 1e18;
		for (int i = 0; i < n; ++i) {
			if (da[i] + db[i] + dc[i] > m) continue;
			ans = min(ans, pref[db[i]] + pref[da[i] + db[i] + dc[i]]);
		}
		cout << ans << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

void bfs(vector<ll>* edges,ll n,ll* parent,ll x){
	queue<ll> q;
	bool visited[n];
	REP(i,0,n) visited[i] = 0;

	q.push(x);
	visited[x] = 1;
	while(q.size()){
		ll curr = q.front();
		q.pop();
		for(auto u : edges[curr]){
			if(!visited[u]){
				visited[u] = 1;
				q.push(u);
				parent[u] = curr;
			}
		}
	}
}

int main()
{
	ll t;
	cin>>t;
	while(t--){
		ll n,e,a,b,c;
		cin>>n>>e>>a>>b>>c;

		vector<ll> edges[n];
		// ll* distance = new ll[n]();

		ll arr[e];
		REP(i,0,e){
			cin>>arr[i];
		}

		REP(i,0,e){
			ll x,y;
			cin>>x>>y;
			edges[x-1].push_back(y-1);
			edges[y-1].push_back(x-1);
		}

		ll* parent1 = new ll[n];
		REP(i,0,n) parent1[i] = -1;
		parent1[a-1] = a-1;

		ll* parent2 = new ll[n];
		REP(i,0,n) parent2[i] = -1;
		parent2[b-1] = b-1;

		bfs(edges,n,parent1,a-1);
		bfs(edges,n,parent2,b-1);
		map<pair<ll,ll>,ll> um;

		ll v1 = b-1;
		while(v1 != a-1){
			um[{v1,parent1[v1]}]++;
			um[{parent1[v1],v1}]++;
			v1 = parent1[v1];
		}

		v1 = c-1;
		while(v1 != b-1){
			um[{v1,parent2[v1]}]++;
			um[{parent2[v1],v1}]++;
			v1 = parent2[v1];
		}

		map<pair<ll,ll>,ll> mp;
		vector<ll> v;
		for(auto it:um){
			if(!mp.count({(it.first).second,(it.first).first})){
				mp[{(it.first).first,(it.first).second}] = 1;
				v.push_back(it.second);
			}
		}
		sort(arr,arr+e);
		sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		ll sum = 0;
		REP(i,0,v.size()){
			// cout<<v[i]<<" ";
			sum += v[i]*arr[i];
		}
		cout<<sum<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

void bfs(vector<ll>* edges,ll n,ll* distance,ll x){
	queue<ll> q;
	bool visited[n];
	REP(i,0,n) visited[i] = 0;

	q.push(x);
	visited[x] = 1;
	while(q.size()){
		ll curr = q.front();
		q.pop();
		for(auto u : edges[curr]){
			if(!visited[u]){
				visited[u] = 1;
				distance[u] = distance[curr] + 1;
				q.push(u);
			}
		}
	}
}

int main()
{
	ll t;
	cin>>t;
	while(t--){
		ll n,m,a,b,c;
		cin>>n>>m>>a>>b>>c;
		a--; b--; c--;
		ll arr[m];
		REP(i,0,m) cin>>arr[i];
		vector<ll> edges[n];
		REP(i,0,m){
			ll x,y;
			cin>>x>>y;
			edges[x-1].push_back(y-1);
			edges[y-1].push_back(x-1);
		}
		sort(arr,arr+m);
		ll pref[m+1] = {0};
		REP(i,1,m+1){
			pref[i] = pref[i-1] + arr[i-1];
		}
		ll* distance1 = new ll[n];
		ll* distance2 = new ll[n];
		ll* distance3 = new ll[n];
		bfs(edges,n,distance1,a);
		bfs(edges,n,distance2,b);
		bfs(edges,n,distance3,c);

		// REP(i,0,n) cout<<distance1[i]<<" ";
		// cout<<endl;
		// REP(i,0,n) cout<<distance2[i]<<" ";
		// cout<<endl;
		// REP(i,0,n) cout<<distance3[i]<<" ";
		// cout<<endl;
		// REP(i,1,m) cout<<pref[i]<<" ";
		// cout<<endl;

		ll mini = 1e9;
		REP(i,0,n){
			if(distance1[i] + distance2[i] + distance3[i] > m){
				continue;
			}
			mini = min(mini,pref[distance2[i]] + pref[distance1[i] + distance2[i] + distance3[i]]);
		}
		cout<<mini<<endl;
	}
	return 0;
}


/*
ID: Aman Raj
LANG: C++
TASK: nocows
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long  ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 998244353
//#define mod 3
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;

   /*bool comp(pair<ll,ll> p1, pair<ll,ll> p2)
   {
    if(p1.first!=p2.first)return p1.first < p2.first;
     else return p1.second < p2.second;
   }*/

ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }

   ll findpower(ll a,ll b)
   {
       ll i=0;
       ll c=1;
        while(1)
        {
            c*=2;

            if(c>a)return i;
            i++;
        }
   }

vector<ll> dpfact;
   ll fact(ll a)
   { return dpfact[a];

   }
   /*
   ll gcd(ll a,ll b)
   {
       if(b==0)return a;
       return gcd(b,a%b);
   }
   #define MAXN 1000001

// stores smallest prime factor for every number
int spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (int i=2; i<MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (int i=4; i<MAXN; i+=2)
		spf[i] = 2;

	for (int i=3; i*i<MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (int j=i*i; j<MAXN; j+=i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j]==j)
					spf[j] = i;
		}
	}
}*/

   vector<vector<ll> > v;
    vector<ll> vpar;
     vector<ll>  vdistc;
      vector<ll> vdista;

  int main()
{    fast;
   ll t; cin>>t;
     ll tt=0;
      while(t--)
      {  ll n,m,a,b,c; cin>>n>>m>>a>>b>>c;
          a--;b--;c--;
           v.clear();
            vpar.clear();
             vdista.clear();
              vdistc.clear();
          v.resize(n);
           vpar.resize(n);
            vdistc.resize(n,-1);
             vdista.resize(n,inf);
            ll ans=inf;
             vector<ll> vedge(m);
              for(auto &x:vedge)cin>>x;
               sort(all(vedge));
                for(ll i=1;i<m;i++)
                {
                    vedge[i]+=vedge[i-1];
                }
           for(ll i=0;i<m;i++)
           {
               ll a,b;cin>>a>>b;
                a--;b--;
                 v[a].push_back(b);
                 v[b].push_back(a);
           }
             queue<ll> q;
             vector<ll> visited(n,0);
              q.push(a);
               visited[a]=1;
              vpar[a]=-1;
          vdista[a]=0;
             while(q.size()>0)
             {
                 ll aa=q.front();q.pop();
                //cout<<aa<<"dd"<<endl;
                for(auto x:v[aa])
                { //cout<<x<<endl;
                    if(visited[x])continue;
                     //cout<<"hello";
                      visited[x]=1;
                      q.push(x);
                       vdista[x]=vdista[aa]+1;
                       //cout<<"dfdfd";
                        vpar[x]=aa;
                         //cout<<"dfdfd"<<endl;
                         //if(x==b)goto here;
                }

             }
        here:

              visited.clear();

             queue<ll>  qq;
              qq.push(c);

                vdistc[c]=0;
                 //cout<<"dd";
                  visited.clear();
         visited.resize(n);
          visited[c]=1;
             while(qq.size()>0)
             { ll aa=qq.front();qq.pop();

                for(auto x:v[aa])
                {
                    if(visited[x]==0){
                             visited[x]=1;
                     vdistc[x]= vdistc[aa]+1;
               //cout<<x<<" "<<vdistc[x]<<endl;
                      qq.push(x);}

                }

             }
             //traverse back from b to a
             //for(ll i=0;i<n;i++)cout<<vdistc[i]<<" ";cout<<endl;
              ll p=b;
               ll l=0;
           if(a==b&&b==c){  cout<<0<<endl;continue; }
             while(p!=-1)
             {

                 //cout<<p<<" "<<l<<" "<<dist<<endl;
                  ll tans=inf;if(vdista[b]+vdistc[p]-1<m)tans=  vedge[vdista[b]+vdistc[p]-1];
                   if(l>0)tans+=vedge[l-1];

                 ans=min(ans,tans);

                p=vpar[p];
                l++;

             }

             cout<<ans<<endl;

      }

      return 0;
}


/*
ID: Aman Raj
LANG: C++
TASK: nocows
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long  ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 998244353
//#define mod 3
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;

   /*bool comp(pair<ll,ll> p1, pair<ll,ll> p2)
   {
    if(p1.first!=p2.first)return p1.first < p2.first;
     else return p1.second < p2.second;
   }*/

ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }

   ll findpower(ll a,ll b)
   {
       ll i=0;
       ll c=1;
        while(1)
        {
            c*=2;

            if(c>a)return i;
            i++;
        }
   }

vector<ll> dpfact;
   ll fact(ll a)
   { return dpfact[a];

   }
   /*
   ll gcd(ll a,ll b)
   {
       if(b==0)return a;
       return gcd(b,a%b);
   }
   #define MAXN 1000001

// stores smallest prime factor for every number
int spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (int i=2; i<MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (int i=4; i<MAXN; i+=2)
		spf[i] = 2;

	for (int i=3; i*i<MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (int j=i*i; j<MAXN; j+=i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j]==j)
					spf[j] = i;
		}
	}
}*/

   vector<vector<ll> > v;
    vector<ll> vpar;
     vector<ll>  vdistc;
      vector<ll> vdista;

  int main()
{    fast;
   ll t; cin>>t;
     ll tt=0;
       for(tt=1;tt<=t;tt++)
      {  ll n,m,a,b,c; cin>>n>>m>>a>>b>>c;
          a--;b--;c--;
           v.clear();
            vpar.clear();
             vdista.clear();
              vdistc.clear();
          v.resize(n);
           vpar.resize(n);
            vdistc.resize(n,-1);
             vdista.resize(n,inf);
            ll ans=inf;
             vector<ll> vedge(m);
              for(auto &x:vedge)cin>>x;
               sort(all(vedge));
                for(ll i=1;i<m;i++)
                {
                    vedge[i]+=vedge[i-1];
                }
           for(ll i=0;i<m;i++)
           {
               ll a,b;cin>>a>>b;
                a--;b--;
                 v[a].push_back(b);
                 v[b].push_back(a);
           }
             queue<ll> q;
             vector<ll> visited(n,0);
              q.push(a);
               visited[a]=1;
              vpar[a]=-1;
          vdista[a]=0;
             while(q.size()>0)
             {
                 ll aa=q.front();q.pop();
                //cout<<aa<<"dd"<<endl;
                for(auto x:v[aa])
                { //cout<<x<<endl;
                    if(visited[x])continue;
                     //cout<<"hello";
                      visited[x]=1;
                      q.push(x);
                       vdista[x]=vdista[aa]+1;
                       //cout<<"dfdfd";
                        vpar[x]=aa;
                         //cout<<"dfdfd"<<endl;
                         //if(x==b)goto here;
                }

             }
        here:

              visited.clear();

             queue<ll>  qq;
              qq.push(c);

                vdistc[c]=0;
                 //cout<<"dd";
                  visited.clear();
         visited.resize(n);
          visited[c]=1;
             while(qq.size()>0)
             { ll aa=qq.front();qq.pop();

                for(auto x:v[aa])
                {
                    if(visited[x]==0){
                             visited[x]=1;
                     vdistc[x]= vdistc[aa]+1;
               //cout<<x<<" "<<vdistc[x]<<endl;
                      qq.push(x);}

                }

             }
             //traverse back from b to a
             //for(ll i=0;i<n;i++)cout<<vdistc[i]<<" ";cout<<endl;
              ll p=b;
               ll l=0;
           if(a==b&&b==c){  cout<<0<<endl;continue; }
             while(p!=-1)
             {

                 //cout<<p<<" "<<l<<" "<<dist<<endl;
                  ll tans=inf;if(vdista[b]+vdistc[p]-1<m)tans=  vedge[vdista[b]+vdistc[p]-1];
                   if(l>0)tans+=vedge[l-1];

                 ans=min(ans,tans);

                p=vpar[p];
                l++;

             }

             if(tt==457&&ans==6)
             {
                  for(ll i=0;i<n;i++)for(ll j=0;j<v[i].size();j++)cout<<i<<"_"<<v[i][j]<<"_";
             }
             cout<<ans<<endl;

      }

      return 0;
}


/*
ID: Aman Raj
LANG: C++
TASK: nocows
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long  ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 998244353
//#define mod 3
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;

   /*bool comp(pair<ll,ll> p1, pair<ll,ll> p2)
   {
    if(p1.first!=p2.first)return p1.first < p2.first;
     else return p1.second < p2.second;
   }*/

ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }

   ll findpower(ll a,ll b)
   {
       ll i=0;
       ll c=1;
        while(1)
        {
            c*=2;

            if(c>a)return i;
            i++;
        }
   }

vector<ll> dpfact;
   ll fact(ll a)
   { return dpfact[a];

   }
   /*
   ll gcd(ll a,ll b)
   {
       if(b==0)return a;
       return gcd(b,a%b);
   }
   #define MAXN 1000001

// stores smallest prime factor for every number
int spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (int i=2; i<MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (int i=4; i<MAXN; i+=2)
		spf[i] = 2;

	for (int i=3; i*i<MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (int j=i*i; j<MAXN; j+=i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j]==j)
					spf[j] = i;
		}
	}
}*/

   vector<vector<ll> > v;
    vector<ll> vpar;
     vector<ll>  vdistc;
      vector<ll> vdista;

  int main()
{    fast;
   ll t; cin>>t;
     ll tt=0;
      while(t--)
      {  ll n,m,a,b,c; cin>>n>>m>>a>>b>>c;
          a--;b--;c--;
           v.clear();
            vpar.clear();
             vdista.clear();
              vdistc.clear();
          v.resize(n);
           vpar.resize(n);
            vdistc.resize(n,-1);
             vdista.resize(n,inf);
            ll ans=inf;
             vector<ll> vedge(m);
              for(auto &x:vedge)cin>>x;
               sort(all(vedge));
                for(ll i=1;i<m;i++)
                {
                    vedge[i]+=vedge[i-1];
                }
           for(ll i=0;i<m;i++)
           {
               ll a,b;cin>>a>>b;
                a--;b--;
                 v[a].push_back(b);
                 v[b].push_back(a);
           }
             queue<ll> q;
             vector<ll> visited(n,0);
              q.push(a);
               visited[a]=1;
              vpar[a]=-1;
          vdista[a]=0;
             while(q.size()>0)
             {
                 ll aa=q.front();q.pop();
                //cout<<aa<<"dd"<<endl;
                for(auto x:v[aa])
                { //cout<<x<<endl;
                    if(visited[x])continue;
                     //cout<<"hello";
                      visited[x]=1;
                      q.push(x);
                       vdista[x]=vdista[aa]+1;
                       //cout<<"dfdfd";
                        vpar[x]=aa;
                         //cout<<"dfdfd"<<endl;
                         if(x==b)goto here;
                }

             }
        here:

              visited.clear();

             queue<ll>  qq;
              qq.push(c);

                vdistc[c]=0;
                 //cout<<"dd";
                  visited.clear();
         visited.resize(n);
          visited[c]=1;
             while(qq.size()>0)
             { ll aa=qq.front();qq.pop();

                for(auto x:v[aa])
                {
                    if(visited[x]==0){
                             visited[x]=1;
                     vdistc[x]= vdistc[aa]+1;
               //cout<<x<<" "<<vdistc[x]<<endl;
                      qq.push(x);}

                }

             }
             //traverse back from b to a
             //for(ll i=0;i<n;i++)cout<<vdistc[i]<<" ";cout<<endl;
              ll p=b;
               ll l=0;
           if(a==b&&b==c){  cout<<0<<endl;continue; }
             while(p!=-1)
             {

                 //cout<<p<<" "<<l<<" "<<dist<<endl;
                  ll tans=inf;if(vdista[b]+vdistc[p]-1<m)tans=  vedge[vdista[b]+vdistc[p]-1];
                   if(l>0)tans+=vedge[l-1];

                 ans=min(ans,tans);

                p=vpar[p];l++;

             }

             cout<<ans<<endl;

      }

      return 0;
}


/*
ID: Aman Raj
LANG: C++
TASK: nocows
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long  ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 998244353
//#define mod 3
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;

   /*bool comp(pair<ll,ll> p1, pair<ll,ll> p2)
   {
    if(p1.first!=p2.first)return p1.first < p2.first;
     else return p1.second < p2.second;
   }*/

ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }

   ll findpower(ll a,ll b)
   {
       ll i=0;
       ll c=1;
        while(1)
        {
            c*=2;

            if(c>a)return i;
            i++;
        }
   }

vector<ll> dpfact;
   ll fact(ll a)
   { return dpfact[a];

   }
   /*
   ll gcd(ll a,ll b)
   {
       if(b==0)return a;
       return gcd(b,a%b);
   }
   #define MAXN 1000001

// stores smallest prime factor for every number
int spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (int i=2; i<MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (int i=4; i<MAXN; i+=2)
		spf[i] = 2;

	for (int i=3; i*i<MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (int j=i*i; j<MAXN; j+=i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j]==j)
					spf[j] = i;
		}
	}
}*/

   vector<vector<ll> > v;
    vector<ll> vpar;
     vector<ll>  vdistc;
      vector<ll> vdista;

  int main()
{    fast;
   ll t; cin>>t;
     ll tt=0;
      while(t--)
      {  ll n,m,a,b,c; cin>>n>>m>>a>>b>>c;
          a--;b--;c--;
          v.resize(n);
           vpar.resize(n);
            vdistc.resize(n,-1);
             vdista.resize(n,inf);
            ll ans=inf;
             vector<ll> vedge(m);
              for(auto &x:vedge)cin>>x;
               sort(all(vedge));
                for(ll i=1;i<m;i++)
                {
                    vedge[i]+=vedge[i-1];
                }
           for(ll i=0;i<m;i++)
           {
               ll a,b;cin>>a>>b;
                a--;b--;
                 v[a].push_back(b);
                 v[b].push_back(a);
           }
             queue<ll> q;
             vector<ll> visited(n,0);
              q.push(a);
               visited[a]=1;
              vpar[a]=-1;
          vdista[a]=0;
             while(q.size()>0)
             {
                 ll aa=q.front();q.pop();
                //cout<<aa<<"dd"<<endl;
                for(auto x:v[aa])
                { //cout<<x<<endl;
                    if(visited[x])continue;
                     //cout<<"hello";
                      visited[x]=1;
                      q.push(x);
                       vdista[x]=vdista[aa]+1;
                       //cout<<"dfdfd";
                        vpar[x]=aa;
                         //cout<<"dfdfd"<<endl;
                         if(x==b)goto here;
                }

             }
        here:

              visited.clear();

             queue<ll>  qq;
              qq.push(c);

                vdistc[c]=0;
                 //cout<<"dd";
                  visited.clear();
         visited.resize(n);
          visited[c]=1;
             while(qq.size()>0)
             { ll aa=qq.front();qq.pop();

                for(auto x:v[aa])
                {
                    if(visited[x]==0){
                             visited[x]=1;
                     vdistc[x]= vdistc[aa]+1;
               //cout<<x<<" "<<vdistc[x]<<endl;
                      qq.push(x);}

                }

             }
             //traverse back from b to a
             //for(ll i=0;i<n;i++)cout<<vdistc[i]<<" ";cout<<endl;
              ll p=b;
               ll l=0;
           if(a==b&&b==c){  cout<<0<<endl;continue; }
             while(p!=-1)
             {

                 //cout<<p<<" "<<l<<" "<<dist<<endl;
                  ll tans=  vedge[vdista[b]+vdistc[p]-1];
                   if(l>0)tans+=vedge[l-1];

                 ans=min(ans,tans);

                p=vpar[p];l++;

             }

             cout<<ans<<endl;

      }

      return 0;
}