#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long
#define ff first
#define ss second
using namespace std;

const int N = 1e5 + 10;
vector < int > g[N];
bool vis[N];
bool S[N];

int main()
{
    FAST;
    int Tt; cin >> Tt;
    while(Tt--)
    {

        int n, m, s; cin >> n >> m >> s;

        for(int i = 0; i <= n + 3; i++)
        {
            g[i].clear();
            S[i] = vis[i] = false;
        }

        vector < int > v(s + 1);
        for(int i = 1; i <= s; i++) cin >> v[i];

        for(auto it : v) S[it] = true;

        for(int i = 0; i < m; i++)
        {
            int a, b; cin >> a >> b;
            g[a].push_back(b);
            g[b].push_back(a);
        }

        queue < pair < int , int > > bfs;
        bfs.push({1, 0});

        vector < pair < int , int > > ans;
        while(!bfs.empty())
        {
            int p = bfs.front().ff;
            int pret = bfs.front().ss;
            bfs.pop();

            if(vis[p]) continue;
            vis[p] = true;
            if(pret != 0) ans.push_back({pret, p});
            if(S[p]  && pret != 0) continue;

            for(auto it : g[p])
            {
                bfs.push({it, p});
                if(S[p]) break;
            }
        }

        if(ans.size() != n - 1) { cout << "-1\n"; continue; }

        cout << ans.size() << "\n";
        for(auto it : ans) cout << it.ff << " " << it.ss << "\n";

    }
    return 0;
}