#include <bits/stdc++.h>

using namespace std;

void dfs(int cvor, vector<vector<bool>> &v, vector<bool> &posecen){
    posecen[cvor] = true;

    for(int i = 1; i < v[cvor].size(); i++){
        if(v[cvor][i]&&!posecen[i]){
            dfs(i, v, posecen);
        }
    }
}

bool povezan(int cvor, vector<vector<bool>> &v){
    vector<bool> posecen(v.size(), false);
    dfs(cvor, v, posecen);
    for(int i = 1; i < v.size(); i++){
        if(!posecen[i])
            return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--){
        int n, m, s;
        cin >> n >> m >> s;
        vector<int> nis(s);
        for(int i = 0; i < s; i++){
            cin >> nis[i];
        }
        vector<vector<bool>> v(n+1, vector<bool>(n+1, false));
        for(int i = 0; i < m; i++){
            int a, b;
            cin >> a >> b;
            v[a][b] = true;
            v[b][a] = true;
        }
        /*vector<pair<int, int>> ukloni;
        for(int tren : nis){
            for(int j = 1; j <= n; j++){
                if()
            }
        }*/
        if(!povezan(1,v)){
            cout << "-1\n";
            continue;
        }
        cout << m << "\n";
        for(int i = 1; i <= n; i++){
            for(int j = i+1; j <= n; j++){
                if(v[i][j])
                    cout << i << " " << j << "\n";
            }
        }
    }
    return 0;
}