#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;
template <class T> using indexed_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#define pb push_back
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;
const char nl = '\n';
const long long int ll_MAX=9223372036854775807;


int find_set(int a,vector<int> &parent){
    if(parent[a]==a)return a;
    return parent[a] = find_set(parent[a],parent);

}

void join_pair(int a,int b,vector<int> &vin,vector<int>& parent){
    a = find_set(a,parent);
    b = find_set(b,parent);
    if(a==b)return;
    if(vin[a]>=vin[b]){
        parent[b]=a;
        vin[a]+=vin[b];
    }
    else{
        parent[a]=b;
        vin[b]+=vin[a];
    }




}





int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;

    for(int papa = 0;papa<t;papa++){
        int n,m,s;
        cin>>n>>m>>s;
        vector<int> vin(n);
        vector<int> parent(n);
        for(int i =0;i<n;i++){vin[i]=1;parent[i]=i;}
        bool losi[n]={};
        for(int i =0;i<s;i++){
            int x;
            cin>>x;
            x--;
            losi[x]=true;
        }


        vector<pair<int,int> > losip;
        bool visited[n]={};
        vector<pair<int,int> > ans;
        for(int i =0;i<m;i++){
            int x,y;
            cin>>x>>y;
            x--;y--;


            if(losi[x] && losi[y])continue;
            else if(!losi[x] && !losi[y]){

                    if(find_set(x,parent)==find_set(y,parent))continue;
                    ans.pb({x,y});
                    join_pair(x,y,vin,parent);}
            else losip.pb({x,y});



        }
        for(int i = 0;i<losip.size();i++){
            int los;
            int dobar;
            if(losi[losip[i].first]){
                los = losip[i].first;
                dobar = losip[i].second;
            }
            else {
                dobar = losip[i].first;
                los = losip[i].second;
            }
            if(visited[los])continue;
            else{
                visited[los]=true;
                join_pair(los,dobar,vin,parent);
                ans.pb({losip[i].first,losip[i].second});
            }
        }
        int tlp = find_set(0,parent);
        bool F = true;
        for(int i =0;i<n;i++){
            if(find_set(i,parent)!=tlp)F=false;
        }
        if(!F)cout<<-1<<nl;
        else{
            cout<<ans.size()<<nl;
            for(auto u:ans){
                cout<<u.first+1<<" "<<u.second+1<<nl;
            }
        }


    }

    return 0;
}