#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define MAXN 300010
#define pii pair <ll, ll>

using namespace std;

vector <ll> DSU(MAXN);
vector <ll> SIZE(MAXN);
vector <bool> red(MAXN);
vector <ll> cnt(MAXN);
vector <pii> res;

ll root(ll x)
{
    if(x == DSU[x]) return x;
    return DSU[x] = root(DSU[x]);
}

void connect(ll x, ll y)
{
    ll X = x, Y = y;
    x = root(x);
    y = root(y);
    if(x == y) return;
    res.push_back({X, Y});
    if(red[x]) cnt[x]++;
    if(red[y]) cnt[y]++;
    if(SIZE[x] < SIZE[y]) swap(x, y);
    SIZE[x] += SIZE[y];
    SIZE[y] = 0;
    DSU[y] = x;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll T, N, M, S;
    cin >> T;
    while(T--)
    {
        cin >> N >> M >> S;
        res.clear();
        for(int i = 1; i <= N; i++){DSU[i] = i; SIZE[i] = 1; cnt[i] = 0; red[i] = false;}
        vector <pii> grane;
        for(int i = 1; i <= S; i++) {ll x; cin >> x; red[x] = true;}
        for(int i = 1; i <= M; i++)
        {
            ll x, y;
            cin >> x >> y;
            grane.push_back({x, y});
        }
        for(auto p : grane)
        {
            ll x = p.first;
            ll y = p.second;
            if(red[x] && red[y]) continue;
            if(red[x]) {if(cnt[x] == 0) connect(x, y);}
            else if(red[y]) {if(cnt[y] == 0) connect(x, y);}
            else connect(x, y);
        }
        bool no = false;
        ll r = root(1);
        for(int i = 1; i <= N; i++) {if(root(i) != r) {cout << -1 << endl; no = true; break;}}
        if(no) continue;
        cout << (ll) res.size() << endl;
        for(auto p : res) cout << p.first << " " << p.second << endl;
    }
    return 0;
}