#include <bits/stdc++.h>

using namespace std;

void dfs(int u, int p, vector<vector<int>>& g, vector<pair<int, int>>& ans, vector<bool>& vis, vector<bool>& los) {
    vis[u] = true;
    if (los[u]) {
        return;
    }
    for (auto& v : g[u]) {
        if (v != p && !vis[v]) {
            ans.push_back({u, v});
            dfs(v, u, g, ans, vis, los);
        }

    }
}

void sol() {
    int n, m, s;
    cin >> n >> m >> s;
    vector<bool> los(n, 0);
    for (int i = 0; i < s; ++i) {
        int x;
        cin >> x;
        --x;
        los[x] = true;
    }
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int st = -1;
    for (int u = 0; u < n; ++u) {
        if (!los[u]) {
            st = u;
            break;
        }
    }
    if (st == -1) {
        cout << "-1\n";
        return;
    }
    vector<pair<int, int>> ans;
    vector<bool> vis(n, 0);
    dfs(st, -1, g, ans, vis, los);
    if (all_of(vis.begin(), vis.end(), [&](bool e){ return e == true; })) {
        cout << ans.size() << '\n';
        for (int i = 0; i < ans.size(); ++i) {
            cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
        }
        return;
    }
    cout << "-1\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        sol();
    }
    return 0;
}