#include <bits/stdc++.h>
#define int int64_t

using namespace std;

int N, M, S;

void solve(){

    set<int> s;

    cin >> N >> M >> S;
    for(int i = 0; i < S; i++){
        int a; cin >> a;
        a--;
        s.insert(a);
    }
    vector<vector<int>> g(N);
    vector<vector<int>> good(N);
    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        if(s.count(a) && !s.count(b)){
            good[a].push_back(b);
        }
        if(!s.count(a) && s.count(b)){
            good[b].push_back(a);
        }
    }
    stack<int> dfs;
    vector<bool> visited(N, false);

    for(int i = 0; i < N; i++){
        if(!s.count(i)){
            dfs.push(i);
            visited[i]=true;
            break;
        }
    }
    vector<pair<int, int>> tree;
    while(!dfs.empty()){
        int top = dfs.top();
        dfs.pop();
        for(int neighbor : g[top]){
            if(visited[neighbor]) continue;
            if(s.count(neighbor)) continue;
            visited[neighbor]=true;
            dfs.push(neighbor);
            tree.push_back({top, neighbor});
        }
    }
    bool possible = true;

    for(int i = 0; i < N; i++){
        if(s.count(i)) continue;
        possible&=visited[i];
    }

    for(int bad : s){
        if(good[bad].size()){
           tree.push_back({bad, good[bad][0]});
        }else{
            possible = false;
        }
    }
    if(!possible){
        cout << "-1\n";
    }else{
        cout << tree.size() << '\n';
        for(auto [x, y] : tree){
            cout << min(x+1, y+1) << " " << max(x+1, y+1) << '\n';
        }
    }
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int tt; cin >> tt;

    while(tt--){
        solve();
    }

    return 0;
}