#include <bits/stdc++.h>

using namespace std;
#define pb push_back

const int N = 1e5 + 5;
vector<int> g[N];
int b[N], f[N], c;
bool vis[N];

void dfs(int s) {
    vis[s] = 1;
    c++;
    for (auto u : g[s]) {
        if (vis[u] || b[u] == 1)    continue;
        dfs(u);
    }
}
void solve() {
    int n, m, s;
    cin >> n >> m >> s;
    for (int i = 1; i <= n; ++i) {
        g[i].clear();
        b[i] = f[i] = vis[i] = 0;
    }
    array<int, 2> e[m+1];
    for (int i = 1; i <= s; ++i) {
        int x;
        cin >> x;
        b[x] = i;
    }
    for (int i = 1; i <= m; ++i) {
        int u, v;
        cin >> u >> v;
        e[i][0] = u, e[i][1] = v;
        g[u].pb(v);
        g[v].pb(u);
    }
    c = 0;
    for (int i = 1; i <= n; ++i) {
        if (!b[i]) {
            dfs(i);
            //cout << c << '\n';
            break;
        }
    }
    map<array<int, 2>, bool> bd;
    for (int i = 1; i <= n; ++i) {
        if (b[i]) {
            for (int j = 0; j < g[i].size(); ++j) {
                if (!b[g[i][j]])    f[i] = g[i][j];
                //cout << i << ":" << g[i][j] << ' ' << f[i] << '\n';
            }
            if (!f[i])  c = 0;
        }
    }
    if (c < n-s || !c) {
        cout << "-1\n";
        return;
    }
    int k = m;
    for (int i = 1; i <= n; ++i) {
        if (b[i]) {
            k -= g[i].size()-1;
            for (auto u : g[i]) {
                if (u != f[i])  bd[{u, i}] = bd[{i, u}] = 1;
            }
        }
    }
    cout << k <<'\n';
    for (int i = 1; i <= m; ++i) {
        if (!bd[{e[i][0], e[i][1]}])    cout << e[i][0] << ' ' << e[i][1] << '\n';
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}