#include <bits/stdc++.h>

using namespace std;

void solve(){
    int n, m, s; cin >> n >> m >> s;

    vector<int> marko(n+1, 0);
    for(int i = 0; i < s; i++){
        int a; cin >> a;
        marko[a] = 1;
    }

    vector<vector<int>> v(n+1);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    queue<int> q;
    q.push(1);
    int cnt = 0;
    vector<bool> flag(n+1, false);
    while(!q.empty()){
        int cvor = q.front();
        q.pop();

        flag[cvor] = true;
        cnt++;
        for(int a : v[cvor]){
            if(!flag[a]) q.push(a);
        }
    }

    if(cnt != n) cout << "-1\n";
    else{
        cout << m << '\n';
        for(int i = 1; i <= n; i++){
            for(int j = 0; j < v[i].size(); j++){
                if(v[i][j] > i) cout << i << ' ' << v[i][j] << '\n';
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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