#include <bits/stdc++.h>

using namespace std;

int n,m,S;
vector<bool> s;
vector<vector<int>> g;
vector<int> sused;
vector<bool> vis;
vector<pair<int,int>> grane;

void dfs(int c, int p){
    vis[c]=true;
    for(auto a:g[c]){
        if(a==p)continue;
        if(vis[a])continue;
        grane.push_back(make_pair(c,a));
        dfs(a,c);
    }
}

void solve(){
    cin>>n>>m>>S;
    s.assign(n,false);
    for(int i=0;i<S;i++){
        int x;
        cin>>x;
        x--;
        s[x]=true;
    }
    g.resize(n);
    for(int i=0;i<n;i++)g[i].clear();
    sused.assign(n,-1);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        if((!s[x])&&(!s[y])){
            g[x].push_back(y);
            g[y].push_back(x);
            continue;
        }
        if(s[x]&&s[y])continue;
        if(s[y])swap(x,y);
        sused[x]=y;
    }

    for(int i=0;i<n;i++){
        if((s[i]&& sused[i]==-1)|| S==n){ //!
            cout<<-1<<endl;
            return;
        }
    }
   // cout<<"lalal"<<endl;

    vis.assign(n,false);
    grane.clear();

    for(int i=0;i<n;i++){
        if(s[i])continue;
        dfs(i,-1);
        break;
    }
/*
    for(int i=0;i<n;i++){
        cout<<i<<"   ";
        for(auto a:g[i])cout<<a<<' ';
        cout<<endl;
    }
    */
    for(int i=0;i<n;i++){
        if((!vis[i]) && (!s[i])){
            cout<<-1<<endl;
            return;
        }
    }
    cout<<n-1<<endl;
    for(auto a:grane)cout<<a.first+1<<' '<<a.second+1<<endl;
    for(int i=0;i<n;i++){
        if(s[i])cout<<i+1<<' '<<sused[i]+1<<endl;
    }

}

int main()
{
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}