#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;
vector<bool>vis;
int root;
void povezi(int u){
if(vis[u])
return;
//cout<<u<<" : "<<endl;
bool b=false;
for(auto& s:g[u]){
if(moze[s]){
//cout<<s<<" --> "<<u<<endl;
tree[s].push_back(u);
b=true;
break;
}
}
if(b&&obojen[u]==false)
moze[u]=true;
vis[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);
vis.clear();
vis.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);
}
root=-1;
for(int i = 1;i<=n;i++)
if(obojen[i]==false){
root=i;
break;
}
if(root==-1){
cout<<-1<<endl;
continue;
}
moze[root]=true;
vis[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<<cnt<<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;
}


}
/*
1
6 7 4
1 2 3 6
5 4
5 1
5 2
5 3
4 6
4 1
4 2


*/
    return 0;
}