#include <bits/stdc++.h>
using namespace std;
vector <vector <int>> g;
vector <bool> vis;
vector <bool> blockcvor;
void dfs (int node)
{
    vis[node]=true;
    for (auto i: g[node])
    {
        if (!vis[i] && !blockcvor[i])
        {
            dfs(i);
        }
    }
}
void dfs1 (int node)
{
    vis[node]=true;
    for (auto i: g[node])
    {
        if (!vis[i])
        {
            cout<<node<<" "<<i<<endl;
            dfs1(node);
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t; cin>>t;
    while (t--)
    {
        int n, m, s;
        cin>>n>>m>>s;
        blockcvor.assign(n, false);
        for (int i=0; i<s; i++)
        {
            int x; cin>>x;
            x--;
            blockcvor[x]=true;
        }
        g.resize(n);
        while (m--)
        {
            int a, b;
            cin>>a>>b;
            a--; b--;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        vis.resize(n, false);
        int glnode=-1;
        for (int i=0; i<n; i++)
        {
            if (!blockcvor[i])
            {
                glnode=i;
                break;
            }
        }
        if (glnode!=-1)
        {
            dfs(glnode);
            bool valid=true;
            for (int i=0; i<n; i++)
            {
                if (!blockcvor[i] && !vis[i])
                {
                    valid=false;
                }
            }
            if (!valid) cout<<-1<<endl;
            else
            {
                cout<<n-1<<endl;
                for (int i=0; i<n; i++)
                {
                    if (blockcvor[i]) cout<<i<<" "<<g[i].back()<<endl;
                }
                vis.assign(n, false);
                dfs1(glnode);
            }
        }
    }
    return 0;
}