#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdint>
#include <utility>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL); 
	int t;
	cin >> t;
	int n;
	int m;
	int s;
	if (m == n - 1) {
		for (int i = 0; i < t; i++)
		{
			cin >> n >> m >> s;
			vector<pair<int,int>> v(s);
			for (int j = 0; j < s; j++)
			{
				int a; cin >> a;
				pair<int, int> p(a, 0);
				v[j] = p;
			}
			for (int k = 0; k < m; k++)
			{
				int x, y;
				cin >> x >> y;
				bool pool = true;
				for(int l=0;l<s;l++)
				{
					if (v[l].first == x) v[l].second++;
					if (v[l].first == y) v[l].second++;
					if (v[l].second > 1) 
					{
						pool = false; break;
					}
				}
			}
		}
	}
}