#include <bits/stdc++.h>
#define ll long long
using namespace std;


int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
short t; cin >> t;
while(t--){
int n, m, s; cin >> n >> m >> s;
int x[s+10], a[m+10], b[m+10], br[s+10];
for ( int i = 0; i < s; i++ ){
    cin >> x[i];
    br[i] = 0;
}
for ( int i = 0; i < m; i++ ){
    cin >> a[i] >> b[i];
    for ( int k = 0; k < s; k++ ){
        if ( a[i] == x[k] ){
            br[k]++;
        }
        if ( b[i] == x[k] ){
            br[k]++;
        }
    }
}
if ( n == m+1 ){
    bool p = true;
    for ( int i = 0; i < s; i++ ){
        if( br[i] >=2 ){
            p = false;
            break;
        }
    }
    if( p == false ){
        cout << -1 << endl;
    }
    else{
        cout << m << endl;
        for ( int j = 0; j < m; j++ ){
            cout << a[j] << " " << b[j] << endl;
        }
    }
}































}

return 0;
}