1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=1e3;
vector<int> e[N+10];
int w0;
bool ans[N+10];
bool vis[N+10];
void f(int n,int m,int k,int w)
{
	if(w>w0)
		return;
	if(m==0)
	{
		if(w<w0)
		{
			w0=w;
			for(int i=1;i<=n;i++)
				ans[i]=false;
		}
		for(int i=1;i<=n;i++)
		{
			if(vis[i])
				ans[i]=true;
		}
		return;
	}
	if(w==k)
		return;
	int a=0,b=0;
	for(int i=1;i<=n;i++)
	{
		if(vis[i])
			continue;
		for(auto v:e[i])
		{
			if(!vis[v])
			{
				a=i;
				b=v;
				break;
			}
		}
		if(a!=0)
			break;
	}
	for(auto x:{a,b})
	{
		int l=0;
		for(auto v:e[x])
		{
			if(!vis[v])
				l++;
		}
		vis[x]=true;
		f(n,m-l,k,w+1);
		vis[x]=false;
	}
	return;
}
void solve()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		e[i].clear();
		ans[i]=false;
	}
	w0=k+1;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	f(n,m,k,0);
	if(w0>k)
		cout<<"-1\n";
	else
	{
		vector<int> vv;
		for(int i=1;i<=n;i++)
		{
			if(ans[i])
				vv.push_back(i);
		}
		cout<<w0<<" "<<vv.size()<<"\n";
		for(auto v:vv)
			cout<<v<<" ";
		cout<<"\n";
	}
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q;
	cin>>q;
	while(q--)
		solve();
	return 0;
}