#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t; cin >> t;
    while(t--){
        ll n,m,s;
        cin >> n >> m >> s;
        vector<ll> nislija(n+1,0);
        for(int i = 0;i < s; i++){
            ll tmp;
            cin >> tmp;
            nislija[tmp]=1;
        }

        vector<vector<ll>>tree(n+1);
        for(int i = 0;i<m;i++){
            ll tmp1,tmp2;
            cin >> tmp1 >> tmp2;
            tree[tmp1].push_back(tmp2);
            tree[tmp2].push_back(tmp1);
        }
        queue<ll> dfs;
        ll mini = LLONG_MAX;
        for(int i = 1;i <=m;i++){
            if(nislija[i]) continue;
            mini=i;
            break;
        }
        dfs.push(mini);
        vector<bool> resen(n,false);
        ll res = 0;
        ll broj = 0;
        while(!dfs.empty() and res != n){
            ll x = dfs.front();
            dfs.pop();
            //cout << x << ' ' << res <<'\n';
            resen[x]=true;res++;
            for(auto dete : tree[x]){
                if(resen[dete] == true or nislija[dete]==1) continue;
                dfs.push(dete);

            }



        }

        if(s+res != n){
            cout << -1 << '\n';
        }

        else {
            for(int i = 1;i <= m; i++){
                if(nislija[i]!=1) continue;
                for(int j = 1;j < tree[i].size(); j++){
                    tree[i].erase(tree[i].begin()+j);
                }
            }
            for(int i = 1;i <= m; i++){
                for(int j=0;j < tree[i].size(); j++){
                    if(i>tree[i][j]) continue;
                    broj++;

                }
            }
            cout << broj << '\n';
            for(int i = 1;i <= m; i++){
                for(int j=0;j < tree[i].size(); j++){
                    if(i>tree[i][j]) continue;
                    cout << i << ' ' << tree[i][j] << '\n';
                }
            }

        }



    }
    return 0;
}