/*
2 
5 4 3
1 4 5
1 2
2 3
3 4
3 5
6 5 2
5 6
1 2
3 4
2 5
4 6
5 6
*/
#include <bits/stdc++.h>
using namespace std;

bool BFS(vector<vector<int>>& graf,vector<bool>& poseceni, vector<bool>& oznacen, vector<pair<int,int>>& losi, int pocetni, set<pair<int,int>>& skup, vector<int>& bfs_pocetak){
	
//	if (marko[pocetni]) return -2;
	poseceni[pocetni] = true;
	queue<int> red;
	red.push(pocetni);
	while(red.size()>0){
		
		int p = red.front();
		for (int i = 0; i < graf[p].size();i++){
			int tr = graf[p][i];
//			cout<<tr<<'\n';
			if (oznacen[tr]){
				
				losi[tr] = make_pair(min(p,tr),max(p,tr));
				if (bfs_pocetak[tr]==-1) bfs_pocetak[tr] = pocetni;
				if (bfs_pocetak[tr]!=pocetni){
//					cout<<'\n'<<tr<<" losi\n";
					return false;
				}
//				stek.push(make_pair(p,tr));
	

				continue;
			}
		
			if (!poseceni[tr]){
				
				poseceni[tr] = true;
				red.push(tr);
				skup.insert(make_pair(p,tr));
				
			}
				
		}
		red.pop();
	}	
	return true;
	
}

void BFS_provera(vector<vector<int>> graf, vector<bool>& poseceni){
	int pocetni = 1;
	poseceni[pocetni] = true;
	queue<int> red;
	red.push(pocetni);
	while(red.size()>0){
		
		int p = red.front();
		for (int i = 0; i < graf[p].size();i++){
			int tr = graf[p][i];
//			cout<<tr<<'\n';
			if (!poseceni[tr]){
				poseceni[tr] = true;
				red.push(tr);	
			}		
		}
		red.pop();
	}	

}


int main(int argc, char** argv) {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T;
	cin>>T;
	while(T--){
		
		int n,m,S;
		cin>>n>>m>>S;
		vector<int> s(S);
		vector<bool> oznacen(n+1,false);
		for (int i = 0; i < S; i++){
			cin>>s[i];
			oznacen[s[i]] = true;
		}
		bool konacno = true;
		vector<vector<int>> graf(n+1);
		for (int i = 0; i < m; i++){
			int p,q;
			cin>>p>>q;
//			if ((oznacen[p]) and (oznacen[q])){
//				cout<<p<<" sused "<<q<<'\n';
//				konacno = false;
//			}
			graf[p].push_back(q);
			graf[q].push_back(p);
		}
		vector<bool> poseceni(n+1,false);
		vector<int> bfs_pocetak(n+1,-1);
		vector<pair<int,int> > losi(n+1,make_pair(-1,-1));
		set<pair<int,int>> skup;
		bool k = true;
		for (int i = 1; i<=n ; i++){
			
			if ((!poseceni[i]) and (!oznacen[i])) k = BFS(graf, poseceni, oznacen, losi, i, skup,bfs_pocetak);
			if (!k) konacno = false;
			
		}
//		if (!konacno) cout<<"2 bfsa su posetila loseg\n";
		/*for (int i = 1; i <= n; i++){
			cout<<i<<": "<<poseceni[i]<<" "<< oznacen[i]<<"  "<<marko1[i]<<"; "<<losi[i].first<<" "<<losi[i].second<<'\n';	
		} */	
		for (int i = 1; i <= n; i++){
			if (losi[i] != make_pair(-1,-1)) skup.insert(make_pair(min(losi[i].first,losi[i].second), max(losi[i].first,losi[i].second)));
		}
		vector<vector<int>> graf_provera(n+1);
		vector<bool> poseceni_provera(n+1,false);
		for (pair<int,int> x:skup){
			int p = x.first,q = x.second;
			graf_provera[p].push_back(q);
			graf_provera[q].push_back(p);
			if ((oznacen[p]) and (oznacen[q])) konacno = false;
		}
		
		BFS_provera(graf_provera, poseceni_provera);
		
		for (int i = 1;i<=n;i++){
			if (poseceni_provera[i] == false) konacno = false;
		}
		if (!konacno) cout<<"-1\n";
		else{
			cout<<skup.size()<<'\n';	
			for (pair<int,int> x: skup){
				cout<<x.first<<" "<<x.second<<'\n';
			}
		}
	}
	
	return 0;
}