#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,scnt;
vector<int>g[100001];
vector<int>tree[100001];
vector<bool>moze;//moze povezati
vector<bool>obojen;
void povezi(int u){
if(moze[u])
return;
bool b=false;
for(auto& s:g[u]){
if(moze[s]){
tree[s].push_back(u);
b=true;
break;
}
}
if(b&&obojen[u]==false)
moze[u]=true;
if(moze[u]){
for(auto& s:g[u])
povezi(s);

}





}
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);
int t;
cin>>t;
while(t--){
for(int i = 0;i<100001;i++)
g[i].clear();

cin>>n>>m>>scnt;
obojen.clear();
obojen.resize(n+1);
moze.clear();
moze.resize(n+1);
for(int i = 0;i<scnt;i++){
int x;
cin>>x;
obojen[x]=true;
}
for(int i = 0;i<m;i++){
int x,y;
cin>>x>>y;
g[x].push_back(y);
g[y].push_back(x);
}
int root=-1;
for(int i = 1;i<=n;i++)
if(obojen[i]==false){
root=i;
break;
}
moze[root]=true;
for(auto& s:g[root])
povezi(s);
int cnt=0;
for(int i =1;i<=n;i++)
cnt+=tree[i].size();
if(cnt!=n-1)
cout<<-1<<endl;
else
cout<<n-1<<endl;
if(cnt==n-1)
for(int i = 1;i<=n;i++){
for(int j = 0;j<tree[i].size();j++)
cout<<i<<" "<<tree[i][j]<<endl;
}


}





    return 0;
}