#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    for(int pdd=0;pdd<t;pdd++){
        int n,m,s;
        cin>>n>>m>>s;
        bool niz[n+1];
        bool dali[n+1];
        int z;
        for(int i=1;i<=s;i++){
            cin>>z;
            niz[z] = true;
            dali[z] = true;
        }
        vector<vector<int> > graph(n+1);
        int x,y;
        vector<pair<int,int> > pairs;
        for(int i=1;i<=m;i++){
            cin>>x>>y;
            if(niz[x] || niz[y]){
                pairs.push_back(make_pair(x,y));
            } else {
                graph[x].push_back(y);
                graph[y].push_back(x);
            }
        }
        vector<pair<int,int> > izlaz;
        for(int i=1;i<=n;i++){
            if(!dali[i]){
                for(int j=0;j<graph[i].size();j++){
                    if(!niz[graph[i][j]]){
                        dali[graph[i][j]] = true;
                        dali[i] = true;
                        izlaz.push_back(make_pair(i,graph[i][j]));
                        j = graph[i].size();
                    }
                }
            }
        }
        for(int i=0;i<pairs.size();i++){

            graph[pairs[i].first].push_back(pairs[i].second);
            graph[pairs[i].second].push_back(pairs[i].first);
        }
        for(int i=1;i<=n;i++){
            if(niz[i]){
                for(int j=0;j<graph[i].size();j++){
                    if(!niz[graph[i][j]]){
                        izlaz.push_back(make_pair(i,graph[i][j]));
                        j = graph[i].size();
                    }
                }
            }
        }
        if(izlaz.size()==n-1){
            cout<<n-1<<endl;
            for(int i=0;i<n-1;i++){
                cout<<min(izlaz[i].first,izlaz[i].second)<<" "<<max(izlaz[i].first,izlaz[i].second)<<endl;
            }
        } else {
            cout<<-1<<endl;
        }
    }
}