#include <bits/stdc++.h>

using namespace std;
#define pb push_back

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

void dfs(int s) {
    vis[s] = 1;
    c++;
    for (auto u : g[s]) {
        if (vis[u])    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] = vis[i] = 0;
    }
    for (int i = 1; i <= s; ++i) {
        int x;
        cin >> x;
        b[x] = 1;
    }
    for (int i = 1; i <= m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for (int i = 1; i <= n; ++i) {
        if (b[i]) {
            int t = -1;
            for (auto u : g[i]) {
                if (!b[u])  t = u;
            }
            if (t == -1) {
                cout << "-1\n";
                return;
            }
            for (auto u : g[i]) {
                if (u != t) {
                    g[u].erase(find(g[u].begin(), g[u].end(), i));
                }
            }
            g[i].clear();
            //cout << i << ' ' << t << '\n';
            g[i].pb(t);
        }
    }
    c = 0;
    dfs(1);
    if (c != n) {
        cout << "-1\n";
        return;
    }
    vector<array<int, 2>> v;
    for (int i = 1; i <= n; ++i) {
        for (auto u : g[i]) {
            if (u > i)  v.pb({u, i});
        }
    }
    cout << v.size() << '\n';
    for (auto [x, y] : v) {
        cout << x << ' ' << y << '\n';
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}