#include <bits/stdc++.h>

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n,m,s; cin >> n >> m >> s;
        vector<int> a(s,0);
        for(int i=0; i<s; i++){int x; cin >> x; x--; a[i]=x;}
        vector<vector<int>> komsije(n);
        for(int i=0; i<m; i++){
            int u,v; cin >> u >> v;
            u--; v--;
            komsije[u].push_back(v);
            komsije[v].push_back(u);
        }
        vector<bool> posjetio(n,0);
        vector<pair<int,int>> grane;
        for(int k : a){
            grane.emplace_back(k,komsije[k][0]);
            posjetio[k]=1;
        }
        int p=0;
        while(p<n && posjetio[p])p++;
        queue<int> q;
        if(p==n){cout << -1 << '\n'; goto dun;}
        q.push(p);
        while(!q.empty()){
            p=q.front(); q.pop();
            posjetio[p]=1;
            for(auto komso : komsije[p]){
                if(!posjetio[komso]){
                    grane.emplace_back(p,komso);
                    q.push(komso);
                }
            }
        }
        for(int i=0; i<n; i++)if(!posjetio[i]){cout << -1 << '\n'; goto dun;}
        cout << grane.size() << '\n';
        for(auto par : grane){
            cout << par.first+1 << ' ' << par.second+1 << '\n';
        }
        dun:;
    }
    return 0;
}