#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <queue>

using namespace std;

const int N = 1e5+2;
const int M = 350;

int n,m,cnt,t,r,k,deg[N];
bool cli[N],nei[N];
vector<int> g[N],cnd[N],w[N];
queue<int> q;

void init(){
  for (int i=1;i<=n;++i){
    g[i].clear();w[i].clear();
    deg[i] = 0;
  }
}

bool step1(){
  cnt = n;
  r = 0;
  for (int i=1;i<=n;++i)
    if (deg[i]<k) q.push(i);
  while (!q.empty()){
    int u = q.front(); q.pop();
    cnt--;
    if (deg[u]==k-1){
      cnd[++r].clear();
      cnd[r].push_back(u);
      w[u].push_back(r);
      for (int i=0;i<g[u].size();++i) if (deg[g[u][i]]>=k-1){
        cnd[r].push_back(g[u][i]);
        w[g[u][i]].push_back(r);
      }
    }
    for (int i=0;i<g[u].size();++i){
      deg[g[u][i]]--;
      if (deg[g[u][i]]==k-1) q.push(g[u][i]);
    }
  }
  if (cnt>0){
    printf("1 %d\n", cnt);
    for (int i=1;i<=n;++i)
      if (deg[i]>=k) printf("%d ", i);
    printf("\n");
    return 1;
  }
  return 0;
}

bool step2(){ // 判断是否存在完全子图
  memset(nei,0,sizeof(nei));
  memset(cli,0,sizeof(cli));
  for (int i=1;i<=n;++i) if (w[i].size()){
    nei[i] = 1;
    for (int j=0;j<g[i].size();++j)
      nei[g[i][j]] = 1;
    for (int j=0;j<w[i].size();++j) if (!cli[w[i][j]]){
      int x = w[i][j];
      for (int l=0;l<cnd[x].size();++l)
        if (!nei[cnd[x][l]]){
          cli[x] = 1;
        }
    }
    for (int j=0;j<g[i].size();++j)
      nei[g[i][j]] = 0;
    nei[i] = 0;
  }
  for (int i=1;i<=r;++i)
    if (!cli[i]){
      printf("2\n");
      for (int j=0;j<cnd[i].size();++j)
        printf("%d ", cnd[i][j]);
      printf("\n");
      return true;
    }
  return false;
}

int main(){
	scanf("%d",&t);
  while (t--){
    scanf("%d%d%d",&n,&m,&k);
    init();
    int x,y;
    for (int i=1;i<=m;++i){
      scanf("%d%d",&x,&y);
      deg[x]++;deg[y]++;
      g[x].push_back(y);g[y].push_back(x);
    }
    if (1ll*k*(k-1)>2ll*m){
      printf("-1\n");
      continue;
    }
    if (step1()) continue;
    if (step2()) continue;
    printf("-1\n");
  }
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <queue>

using namespace std;

const int N = 1e5+2;
const int M = 1005;

int n,m,cnt,t,k,deg[N],w[N];
bool del[N],tag[N],nei[N];
vector<int> g[N],v[N];
queue<int> q;

void init(){
  for (int i=1;i<=n;++i){
    g[i].clear();
    deg[i] = 0;
    tag[i] = 0;
    del[i] = 0;
  }
}

bool step1(){
  cnt = n;
  for (int i=1;i<=n;++i)
    if (deg[i]<k) q.push(i);
  while (!q.empty()){
    int u = q.front(); q.pop();
    del[u] = 1;
    cnt--;
    if (deg[u]==k-1){
      tag[u] = 1; v[u].clear();
      for (int i=0;i<g[u].size();++i)
        if (!del[g[u][i]]) v[u].push_back(g[u][i]);
    }
    for (int i=0;i<g[u].size();++i){
      deg[g[u][i]]--;
      if (deg[g[u][i]]==k-1) q.push(g[u][i]);
    }
  }
  if (cnt>0){
    printf("1 %d\n", cnt);
    for (int i=1;i<=n;++i)
      if (deg[i]>=k) printf("%d ", i);
    printf("\n");
    return 1;
  }
  return 0;
}

bool step2(){ // 判断是否存在完全子图
  for (int i=1;i<=n;++i) if (tag[i]) {
    cout << i << ":" << endl;
    memset(nei,0,sizeof(nei));
    nei[i] = 1;
    for (int j=0;j<v[i].size();++j)
      nei[v[i][j]] = 1;
    bool ok = true;
    for (int j=0;j<v[i].size();++j){
      int u = v[i][j], cnt = 0;
      for (int l=0;l<g[u].size();++l){
        if (nei[g[u][l]]) cnt++;
      }
      if (cnt<k-1) {
        ok = false;
        break;
      }
    }
    if (ok) {
      printf("2\n");
      for (int j=0;j<v[i].size();++j)
        printf("%d ", v[i][j]);
      printf("%d\n", i);
      return true;
    }
  }
  return false;
}

int main(){
	scanf("%d",&t);
  while (t--){
    scanf("%d%d%d",&n,&m,&k);
    init();
    int x,y;
    for (int i=1;i<=m;++i){
      scanf("%d%d",&x,&y);
      deg[x]++;deg[y]++;
      g[x].push_back(y);g[y].push_back(x);
    }
    if (k>2ll*m){
      printf("-1\n");
      continue;
    }
    if (step1()) continue;
    if (step2()) continue;
    printf("-1\n");
  }
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <queue>

using namespace std;

const int N = 1e5+2;
const int M = 350;

int n,m,cnt,t,r,k,deg[N];
bool cli[N],nei[N];
vector<int> g[N],cnd[N],w[N];
queue<int> q;

void init(){
  for (int i=1;i<=n;++i){
    g[i].clear();w[i].clear();
    deg[i] = 0;
  }
}

bool step1(){
  cnt = n;
  r = 0;
  for (int i=1;i<=n;++i)
    if (deg[i]<k) q.push(i);
  while (!q.empty()){
    int u = q.front(); q.pop();
    cnt--;
    if (deg[u]==k-1){
      cnd[++r].clear();
      cnd[r].push_back(u);
      w[u].push_back(r);
      for (int i=0;i<g[u].size();++i){
        cnd[r].push_back(g[u][i]);
        w[g[u][i]].push_back(r);
      }
    }
    for (int i=0;i<g[u].size();++i){
      deg[g[u][i]]--;
      if (deg[g[u][i]]==k-1) q.push(g[u][i]);
    }
  }
  if (cnt>0){
    printf("1 %d\n", cnt);
    for (int i=1;i<=n;++i)
      if (deg[i]>=k) printf("%d ", i);
    printf("\n");
    return 1;
  }
  return 0;
}

bool step2(){ // 判断是否存在完全子图
  memset(nei,0,sizeof(nei));
  memset(cli,0,sizeof(cli));
  // cout << r << endl;
  // for (int i=1;i<=r;++i){
  //   for (int j=0;j<cnd[i].size();++j)
  //     cout << cnd[i][j] << " ";
  //   cout << endl;
  // }
  for (int i=1;i<=n;++i){
    nei[i] = 1;
    for (int j=0;j<g[i].size();++j)
      nei[g[i][j]] = 1;
    for (int j=0;j<w[i].size();++j) if (!cli[w[i][j]]){
      int x = w[i][j];
      for (int l=0;l<cnd[x].size();++l)
        if (!nei[cnd[x][l]]){
          cli[x] = 1;
        }
    }
    for (int j=0;j<g[i].size();++j)
      nei[j] = 0;
    nei[i] = 0;
  }
  for (int i=1;i<=r;++i)
    if (!cli[i]){
      printf("2\n");
      for (int j=0;j<cnd[i].size();++j)
        printf("%d ", cnd[i][j]);
      printf("\n");
      return true;
    }
  return false;
}

int main(){
	scanf("%d",&t);
  while (t--){
    scanf("%d%d%d",&n,&m,&k);
    init();
    int x,y;
    for (int i=1;i<=m;++i){
      scanf("%d%d",&x,&y);
      deg[x]++;deg[y]++;
      g[x].push_back(y);g[y].push_back(x);
    }
    if (k>2ll*m){
      printf("-1\n");
      continue;
    }
    if (step1()) continue;
    if (step2()) continue;
    printf("-1\n");
  }
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

vector<int> G[100010],remain[100010];
int siz[100010];
struct node{
	int x;
	bool operator <(const node &a)const{return siz[x]>siz[a.x];}
};

bool del[100010],in[100010];
int T,n,m,k,ans[100010];
map<int,bool>side[100010];

int main(){
	T=read();
	while(T--)
	{
		n=read(),m=read(),k=read();

		int lmt=sqrt(2*m)+1;
		if(k>lmt) {
			for(int i=1,x,y;i<=m;i++) x=read(),y=read();
			printf("-1\n");
		}
		else {
			for(int i=1;i<=n;i++) G[i].clear(),side[i].clear(),siz[i]=del[i]=in[i]=0;
			int tot=0,got=0;
			for(int i=1,x,y;i<=m;i++){
				x=read(),y=read();
				G[x].pb(y),G[y].pb(x);
				siz[x]++,siz[y]++;
				side[x][y]=side[y][x]=1;
	//			printf("side:%d %d\n",x,y);
			}
			queue<int>line;
			for(int i=1;i<=n;i++) if(siz[i]<k) line.push(i),in[i]=1;

			while(!line.empty()){
				int u=line.front();line.pop();
//				printf("Case %d:%d\n",u,siz[u]);
				del[u]=1;
				if(siz[u]==k-1){
					tot++;remain[tot].clear();remain[tot].pb(u);
					for(auto v:G[u]) if(!del[v]) remain[tot].pb(v);
				}
				for(auto v:G[u]) {
					siz[v]--;
					if(siz[v]<k&&!in[v]) line.push(v),in[v]=1;
				}
			}
			int cnt=0;
			for(int i=1;i<=n;i++) if(!del[i]) ans[++cnt]=i;
			if(cnt){
				printf("1 %d\n",cnt);
				for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
				printf("\n");got=1;
			}

			if(!got){
				for(int i=1;i<=tot;i++) {
					bool fail=0;
					for(int j=0;j<remain[i].size();j++)
					{
						for(int k=j+1;k<remain[i].size();k++)
						{
							int u=remain[i][j],v=remain[i][k];
							if(!side[u].count(v)) {
								fail=1;break;
							}
						}if(fail)break;
					}
					if(!fail){
						printf("2\n");
						for(auto u:remain[i]) printf("%d ",u);
						printf("\n");got=1;
						break;
					}
				}
			}
			if(!got) printf("-1\n");
		}
	}return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

vector<int> G[100010],remain[100010];
int siz[100010];
struct node{
	int x;
	bool operator <(const node &a)const{return siz[x]>siz[a.x];}
};

bool in[100010];
int T,n,m,k,ans[100010];
map<int,bool>side[100010];

int main(){
	T=read();
	while(T--)
	{
		n=read(),m=read(),k=read();
		int lmt=sqrt(2*m)+1;
		if(k>lmt) printf("-1\n");
		else {
			for(int i=1;i<=n;i++) G[i].clear(),side[i].clear(),siz[i]=0;
			int tot=0,got=0;
			for(int i=1,x,y;i<=m;i++)
			{
				x=read(),y=read();
				G[x].pb(y),G[y].pb(x);
				siz[x]++,siz[y]++;
				side[x][y]=side[y][x]=1;
			}
			priority_queue<node>line;
			for(int i=1;i<=n;i++) line.push((node){i}),in[i]=1;
			while(!line.empty())
			{
				int u=line.top().x;line.pop();in[u]=0;
//				printf("Case :%d %d\n",u,siz[u]);
				if(siz[u]==k-1){
					tot++;remain[tot].clear();
					for(auto v:G[u]) if(in[v]) remain[tot].pb(v);
					remain[tot].pb(u);
				}

				if(siz[u]>=k)
				{
					int cnt=0;ans[++cnt]=u;
					while(!line.empty()) ans[++cnt]=line.top().x,line.pop();
					printf("1 %d\n",cnt);
					for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
					printf("\n");got=1;
				}
				in[u]=0;
				for(auto v:G[u]) siz[v]--;
			}
			if(!got){
				for(int i=1;i<=tot;i++) {
					bool fail=0;
					for(auto u:remain[i])
					{
						for(auto v:remain[i])
						{
							if(u!=v&&!side[u][v])
							{
								fail=1;break;
							}
						}if(fail)break;
					}
					if(!fail){
						printf("2\n");
						for(auto u:remain[i]) printf("%d ",u);
						printf("\n");got=1;
						break;
					}
				}
			}
			if(!got) printf("-1\n");
		}
	}return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

vector<int> G[100010],remain[100010];
int siz[100010];
struct node{
	int x;
	bool operator <(const node &a)const{return siz[x]>siz[a.x];}
};

bool del[100010],in[100010];
int T,n,m,k,ans[100010];
map<int,bool>side[100010];

int main(){
	T=read();
	while(T--)
	{
		n=read(),m=read(),k=read();
		for(int i=1;i<=n;i++) G[i].clear(),side[i].clear(),siz[i]=del[i]=in[i]=0;
		int tot=0,got=0;
		for(int i=1,x,y;i<=m;i++){
			x=read(),y=read();
			G[x].pb(y),G[y].pb(x);
			siz[x]++,siz[y]++;
			side[x][y]=side[y][x]=1;
//			printf("side:%d %d\n",x,y);
		}
		int lmt=sqrt(2*m)+1;
		if(k>lmt) printf("-1\n");
		else {
			queue<int>line;
			for(int i=1;i<=n;i++) if(siz[i]<k) line.push(i),in[i]=1;

			while(!line.empty()){
				int u=line.front();line.pop();
//				printf("Case %d:%d\n",u,siz[u]);
				del[u]=1;
				if(siz[u]==k-1){
					tot++;remain[tot].clear();remain[tot].pb(u);
					for(auto v:G[u]) if(!del[v]) remain[tot].pb(v);
				}
				for(auto v:G[u]) {
					siz[v]--;
					if(siz[v]<k&&!in[v]) line.push(v),in[v]=1;
				}
			}
			int cnt=0;
			for(int i=1;i<=n;i++) if(!del[i]) ans[++cnt]=i;
			if(cnt){
				printf("1 %d\n",cnt);
				for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
				printf("\n");got=1;
			}

			if(!got){
				for(int i=1;i<=tot;i++) {
					bool fail=0;
//					for(auto u:remain[i]) printf("%d ",u);printf("\n");
					for(auto u:remain[i])
					{
						for(auto v:remain[i])
						{
							if(u!=v&&!side[u][v]){fail=1;break;}
						}if(fail)break;
					}
					if(!fail){
						printf("2\n");
						for(auto u:remain[i]) printf("%d ",u);
						printf("\n");got=1;
						break;
					}
				}
			}
			if(!got) printf("-1\n");
		}
	}return 0;
}
/*
4
7 5 2
3 5
1 3
2 6
1 4
1 2
3 1 1
2 3
5 7 5
1 5
1 2
2 3
2 4
1 3
3 5
3 4
6 11 4
1 3
1 2
1 5
5 6
3 5
4 5
1 6
2 6
1 4
4 6
3 4
*/


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

vector<int> G[100010],remain[100010];
int siz[100010];
struct node{
	int x;
	bool operator <(const node &a)const{return siz[x]>siz[a.x];}
};

bool del[100010];
int T,n,m,k,ans[100010];
map<int,bool>side[100010];

int main(){
	T=read();
	while(T--)
	{
		n=read(),m=read(),k=read();
		int lmt=sqrt(2*m)+1;
		if(k>lmt) printf("-1\n");
		else {
			for(int i=1;i<=n;i++) G[i].clear(),side[i].clear(),siz[i]=del[i]=0;
			int tot=0,got=0;
			for(int i=1,x,y;i<=m;i++)
			{
				x=read(),y=read();
				G[x].pb(y),G[y].pb(x);
				siz[x]++,siz[y]++;
				side[x][y]=side[y][x]=1;
			}
			queue<int>line;
			for(int i=1;i<=n;i++){
				if(siz[i]<k) line.push(i);
			}
			while(!line.empty())
			{
				int u=line.front();line.pop();del[u]=1;
//				printf("Case :%d %d\n",u,siz[u]);
				if(siz[u]==k-1)
				{
					tot++;remain[tot].clear();
					for(auto v:G[u]) if(!del[v]) remain[tot].pb(v);
					remain[tot].pb(u);
				}
				for(auto v:G[u]) {
					siz[v]--;
					if(siz[v]<k&&!del[v]) line.push(v);
				}
			}int cnt=0;
			for(int i=1;i<=n;i++) if(!del[i]) ans[++cnt]=i;
			if(cnt){
				printf("1 %d\n",cnt);
				for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
				printf("\n");got=1;
			}

			if(!got){
				for(int i=1;i<=tot;i++) {
					bool fail=0;
//					for(auto u:remain[i]) printf("%d ",u);printf("\n");
					for(auto u:remain[i])
					{
						for(auto v:remain[i])
						{
							if(u!=v&&!side[u][v]){fail=1;break;}
						}if(fail)break;
					}
					if(!fail){
						printf("2\n");
						for(auto u:remain[i]) printf("%d ",u);
						printf("\n");got=1;
						break;
					}
				}
			}
			if(!got) printf("-1\n");
		}
	}return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

vector<int> G[100010],remain[100010];
int siz[100010];
struct node{
	int x;
	bool operator <(const node &a)const{return siz[x]>siz[a.x];}
};

bool del[100010],in[100010];
int T,n,m,k,ans[100010];
map<int,bool>side[100010];

int main(){
	T=read();
	while(T--)
	{
		n=read(),m=read(),k=read();
		int lmt=sqrt(2*m)+1;
		if(k>lmt) printf("-1\n");
		else {
			for(int i=1;i<=n;i++) G[i].clear(),side[i].clear(),siz[i]=del[i]=in[i]=0;
			int tot=0,got=0;
			for(int i=1,x,y;i<=m;i++)
			{
				x=read(),y=read();
				G[x].pb(y),G[y].pb(x);
				siz[x]++,siz[y]++;
				side[x][y]=side[y][x]=1;
			}
			queue<int>line;
			for(int i=1;i<=n;i++) if(siz[i]<k) line.push(i),in[i]=1;

			while(!line.empty()){
				int u=line.front();line.pop();
				del[u]=1;
				if(siz[u]==k-1)
				{
					tot++;remain[tot].clear();remain[tot].pb(u);
					for(auto v:G[u]) if(!del[v]) remain[tot].pb(v);
				}
				for(auto v:G[u]) {
					siz[v]--;
					if(siz[v]<k&&!in[v]) line.push(v),in[v]=1;
				}
			}
			int cnt=0;
			for(int i=1;i<=n;i++) if(!del[i]) ans[++cnt]=i;
			if(cnt){
				printf("1 %d\n",cnt);
				for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
				printf("\n");got=1;
			}

			if(!got){
				for(int i=1;i<=tot;i++) {
					bool fail=0;
//					for(auto u:remain[i]) printf("%d ",u);printf("\n");
					for(auto u:remain[i])
					{
						for(auto v:remain[i])
						{
							if(u!=v&&!side[u][v]){fail=1;break;}
						}if(fail)break;
					}
					if(!fail){
						printf("2\n");
						for(auto u:remain[i]) printf("%d ",u);
						printf("\n");got=1;
						break;
					}
				}
			}
			if(!got) printf("-1\n");
		}
	}return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

vector<int> G[100010],remain[100010];
int siz[100010];
struct node{
	int x;
	bool operator <(const node &a)const{return siz[x]>siz[a.x];}
};

bool del[100010];
int T,n,m,k,ans[100010];
map<int,bool>side[100010];

int main(){
	T=read();
	while(T--)
	{
		n=read(),m=read(),k=read();
		int lmt=sqrt(2*m)+1;
		if(k>lmt) printf("-1\n");
		else {
			for(int i=1;i<=n;i++) G[i].clear(),side[i].clear(),siz[i]=del[i]=0;
			int tot=0,got=0;
			for(int i=1,x,y;i<=m;i++)
			{
				x=read(),y=read();
				G[x].pb(y),G[y].pb(x);
				siz[x]++,siz[y]++;
				side[x][y]=side[y][x]=1;
			}
			queue<int>line;
			for(int i=1;i<=n;i++){
				if(siz[i]<k) line.push(i),del[i]=1;
			}
			while(!line.empty())
			{
				int u=line.front();line.pop();
//				printf("Case :%d %d\n",u,siz[u]);
				if(siz[u]==k-1)
				{
					int now=0;
					for(auto v:G[u]) if(!del[v]) now++;
					if(now==k-1){
						tot++;remain[tot].clear();
						for(auto v:G[u]) if(!del[v]) remain[tot].pb(v);
						remain[tot].pb(u);
					}
				}
				for(auto v:G[u]) {
					siz[v]--;
					if(siz[v]<k&&!del[v]) line.push(v),del[v]=1;
				}
			}int cnt=0;
			for(int i=1;i<=n;i++) if(!del[i]) ans[++cnt]=i;
			if(cnt){
				printf("1 %d\n",cnt);
				for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
				printf("\n");got=1;
			}

			if(!got){
				for(int i=1;i<=tot;i++) {
					bool fail=0;
//					for(auto u:remain[i]) printf("%d ",u);printf("\n");
					for(auto u:remain[i])
					{
						for(auto v:remain[i])
						{
							if(u!=v&&!side[u][v]){fail=1;break;}
						}if(fail)break;
					}
					if(!fail){
						printf("2\n");
						for(auto u:remain[i]) printf("%d ",u);
						printf("\n");got=1;
						break;
					}
				}
			}
			if(!got) printf("-1\n");
		}
	}return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

vector<int> G[100010],remain[100010];
int siz[100010];
struct node{
	int x;
	bool operator <(const node &a)const{return siz[x]>siz[a.x];}
};

bool del[100010],in[100010];
int T,n,m,k,ans[100010];
map<int,bool>side[100010];

int main(){
	T=read();
	while(T--)
	{
		n=read(),m=read(),k=read();
		int lmt=sqrt(2*m)+1;
		if(k>lmt) printf("-1\n");
		else {
			for(int i=1;i<=n;i++) G[i].clear(),side[i].clear(),siz[i]=del[i]=0;
			int tot=0,got=0;
			for(int i=1,x,y;i<=m;i++)
			{
				x=read(),y=read();
				G[x].pb(y),G[y].pb(x);
				siz[x]++,siz[y]++;
				side[x][y]=side[y][x]=1;
			}
			queue<int>line;
			for(int i=1;i<=n;i++) if(siz[i]<k) line.push(i),in[i]=1;

			while(!line.empty()){
				int u=line.front();line.pop();
				del[u]=1;
				if(siz[u]==k-1)
				{
					tot++;remain[tot].clear();remain[tot].pb(u);
					for(auto v:G[u]) if(!del[v]) remain[tot].pb(v);
				}
				for(auto v:G[u]) {
					siz[v]--;
					if(siz[v]<k&&!in[v]) line.push(v),in[v]=1;
				}
			}
			int cnt=0;
			for(int i=1;i<=n;i++) if(!del[i]) ans[++cnt]=i;
			if(cnt){
				printf("1 %d\n",cnt);
				for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
				printf("\n");got=1;
			}

			if(!got){
				for(int i=1;i<=tot;i++) {
					bool fail=0;
//					for(auto u:remain[i]) printf("%d ",u);printf("\n");
					for(auto u:remain[i])
					{
						for(auto v:remain[i])
						{
							if(u!=v&&!side[u][v]){fail=1;break;}
						}if(fail)break;
					}
					if(!fail){
						printf("2\n");
						for(auto u:remain[i]) printf("%d ",u);
						printf("\n");got=1;
						break;
					}
				}
			}
			if(!got) printf("-1\n");
		}
	}return 0;
}


#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fir first
#define sec second
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

vector<int> G[100010],remain[100010];
int siz[100010];
struct node{
	int x;
	bool operator <(const node &a)const{return siz[x]>siz[a.x];}
};

bool del[100010],in[100010];
int T,n,m,k,ans[100010],tmp[100010];
unordered_map<int,bool>side[100010];

int main(){
	T=read();
	while(T--)
	{
		n=read(),m=read(),k=read();

		int lmt=sqrt(2*m)+1;
		if(k>lmt) {
			for(int i=1,x,y;i<=m;i++) x=read(),y=read();
			printf("-1\n");
		}
		else {
			for(int i=1;i<=n;i++) G[i].clear(),side[i].clear(),siz[i]=del[i]=in[i]=0;
			int tot=0,got=0;
			for(int i=1,x,y;i<=m;i++){
				x=read(),y=read();
				G[x].pb(y),G[y].pb(x);
				siz[x]++,siz[y]++;
				side[x][y]=side[y][x]=1;
	//			printf("side:%d %d\n",x,y);
			}
			queue<int>line;
			for(int i=1;i<=n;i++) if(siz[i]<k) line.push(i),in[i]=1;

			while(!line.empty()){
				int u=line.front();line.pop();
//				printf("Case %d:%d\n",u,siz[u]);
				del[u]=1;
				if(siz[u]==k-1){
					tot++;remain[tot].clear();remain[tot].pb(u);
					for(auto v:G[u]) if(!del[v]) remain[tot].pb(v);
				}
				for(auto v:G[u]) {
					siz[v]--;
					if(siz[v]<k&&!in[v]) line.push(v),in[v]=1;
				}
			}
			int cnt=0;
			for(int i=1;i<=n;i++) if(!del[i]) ans[++cnt]=i;
			if(cnt){
				printf("1 %d\n",cnt);
				for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
				printf("\n");got=1;
			}

			if(!got){
				for(int i=1;i<=tot;i++) {
					bool fail=0;int all=remain[i].size();
					for(int j=0;j<all;j++) tmp[j]=remain[i][j];
					for(int j=0;j<all;j++){
						for(int k=j+1;k<all;k++)
						{
							int u=tmp[j],v=tmp[k];
							if(!side[u].count(v)) {
								fail=1;break;
							}
						}if(fail)break;
					}
					if(!fail){
						printf("2\n");
						for(auto u:remain[i]) printf("%d ",u);
						printf("\n");got=1;
						break;
					}
				}
			}
			if(!got) printf("-1\n");
		}
	}return 0;
}


#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define mod 10000007
#define ll long long
//#define file
using namespace std;

struct type{int s,x;} s;
int a[200001][2],ls[100001],d[100001],dg[100001],Tot,T,n,m,K,i,j,k,l,len,tot,tp;
int hs[mod][2],ans[100001];
int b[100001],t;
bool bz[100001],Bz;
priority_queue<type> hp;
bool operator < (type a,type b) {return !(a.s<b.s);}

void New(int x,int y) {++len;a[len][0]=y;a[len][1]=ls[x];ls[x]=len;}
void swap(int &x,int &y) {int z=x;x=y;y=z;}
void add(int x,int y)
{
	if (x>y) swap(x,y);
	ll s=(1ll*x*233333+1ll*y*233)%mod;
	while (hs[s][0] && !(hs[s][0]==x && hs[s][1]==y)) s=(s+1)%mod;
	if (!hs[s][0]) hs[s][0]=x,hs[s][1]=y,d[++Tot]=s;
}
bool find(int x,int y)
{
	if (x>y) swap(x,y);
	ll s=(1ll*x*233333+1ll*y*233)%mod;
	while (hs[s][0] && !(hs[s][0]==x && hs[s][1]==y)) s=(s+1)%mod;
	if (!hs[s][0]) return 0;
	return 1;
}

int main()
{
	#ifdef file
	freopen("b.in","r",stdin);
	#endif

	scanf("%d",&T);
	for (;T;--T)
	{
		while (!hp.empty()) hp.pop();
		scanf("%d%d%d",&n,&m,&K),len=tot=Tot=0;
		memset(ls,0,(n+1)*4);
		memset(dg,0,(n+1)*4);
		memset(bz,0,n+1);
		fo(i,1,m) scanf("%d%d",&j,&k),New(j,k),New(k,j),add(j,k),++dg[j],++dg[k];
		fo(i,1,n) hp.push(type{dg[i],i});

		while (!hp.empty())
		{
			s=hp.top(),hp.pop();
			if (dg[s.x]!=s.s || bz[s.x]) continue;

			if (s.s>=K)
			{
				tp=1;
				fo(i,1,n) if (!bz[i]) ans[++tot]=i;
				break;
			}
			else
			if (s.s==K-1 && 1ll*K*(K-1)/2<=m)
			{
				t=0,Bz=1;
				for (i=ls[s.x]; i; i=a[i][1]) if (!bz[a[i][0]]) b[++t]=a[i][0];
				fo(i,1,t-1)
				{
					fo(j,i+1,t)
					if (!find(b[i],b[j]))
					{
						Bz=0;
						break;
					}
					if (!Bz) break;
				}

				if (Bz)
				{
					tp=2;tot=1,ans[1]=s.x;
					fo(i,1,t) ans[++tot]=b[i];
					break;
				}
			}

			bz[s.x]=1,m-=s.s;
			for (i=ls[s.x]; i; i=a[i][1])
			if (!bz[a[i][0]])
			--dg[a[i][0]],hp.push(type{dg[a[i][0]],a[i][0]});
		}
		fo(i,1,Tot) hs[d[i]][0]=hs[d[i]][1]=0;

		if (!tot) cout<<-1<<endl;
		else
		{
			if (tp==1) cout<<tp<<" "<<tot<<endl;
			else cout<<tp<<endl;
			fo(i,1,tot) cout<<ans[i]<<" ";
			cout<<endl;
		}
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define mod 10000007
#define ll long long
//#define file
using namespace std;

struct type{int s,x;} s;
int a[200001][2],ls[100001],d[100001],dg[100001],Tot,T,n,m,K,i,j,k,l,len,tot,tp;
int hs[mod][2],ans[100001];
int b[100001],t;
bool bz[100001],Bz;
priority_queue<type> hp;
bool operator < (type a,type b) {return !(a.s<b.s);}

void New(int x,int y) {++len;a[len][0]=y;a[len][1]=ls[x];ls[x]=len;}
void swap(int &x,int &y) {int z=x;x=y;y=z;}
void add(int x,int y)
{
	if (x>y) swap(x,y);
	ll s=(1ll*x*233333+y)%mod;
	while (hs[s][0] && !(hs[s][0]==x && hs[s][1]==y)) s=(s+1)%mod;
	if (!hs[s][0]) hs[s][0]=x,hs[s][1]=y,d[++Tot]=s;
}
bool find(int x,int y)
{
	if (x>y) swap(x,y);
	ll s=(1ll*x*233333+y)%mod;
	while (hs[s][0] && !(hs[s][0]==x && hs[s][1]==y)) s=(s+1)%mod;
	if (!hs[s][0]) return 0;
	return 1;
}

int main()
{
	#ifdef file
	freopen("b.in","r",stdin);
	#endif

	scanf("%d",&T);
	for (;T;--T)
	{
		scanf("%d%d%d",&n,&m,&K),len=tot=Tot=0;
		memset(ls,0,(n+1)*4);
		memset(dg,0,(n+1)*4);
		memset(bz,0,n+1);
		fo(i,1,m) scanf("%d%d",&j,&k),New(j,k),New(k,j),add(j,k),++dg[j],++dg[k];
		fo(i,1,n) hp.push(type{dg[i],i});

		while (!hp.empty())
		{
			s=hp.top(),hp.pop();
			if (dg[s.x]!=s.s || bz[s.x]) continue;

			if (s.s>=K)
			{
				tp=1;
				fo(i,1,n) if (!bz[i]) ans[++tot]=i;
				break;
			}
			else
			if (s.s==K-1 && 1ll*K*(K-1)/2<=m)
			{
				t=0,Bz=1;
				for (i=ls[s.x]; i; i=a[i][1]) if (!bz[a[i][0]]) b[++t]=a[i][0];
				fo(i,1,t-1)
				{
					fo(j,i+1,t)
					if (!find(b[i],b[j]))
					{
						Bz=0;
						break;
					}
					if (!Bz) break;
				}

				if (Bz)
				{
					tp=2;tot=1,ans[1]=s.x;
					fo(i,1,t) ans[++tot]=b[i];
					break;
				}
			}

			bz[s.x]=1,m-=s.s;
			for (i=ls[s.x]; i; i=a[i][1])
			if (!bz[a[i][0]])
			--dg[a[i][0]],hp.push(type{dg[a[i][0]],a[i][0]});
		}
		fo(i,1,Tot) hs[d[i]][0]=hs[d[i]][1]=0;

		if (!tot) cout<<-1<<endl;
		else
		{
			if (tp==1) cout<<tp<<" "<<tot<<endl;
			else cout<<tp<<endl;
			fo(i,1,tot) cout<<ans[i]<<" ";
			cout<<endl;
		}
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
//#define file
using namespace std;

struct type{int s,x;} s;
bool operator < (type a,type b) {return !(a.s<b.s);}
priority_queue<type> hp;
int a[400001][2],ls[200001],d[200001],T,n,m,K,i,j,k,l,len,t,tp,Ans;
bool bz[200002];
int ans[200002];

void New(int x,int y) {++len;a[len][0]=y;a[len][1]=ls[x];ls[x]=len;}

int main()
{
	#ifdef file
	freopen("b.in","r",stdin);
	#endif

	scanf("%d",&T);
	for (;T;--T)
	{
		while (!hp.empty()) hp.pop();
		scanf("%d%d%d",&n,&m,&K),len=0;
		memset(ls,0,4*(n+1));
		memset(d,0,4*(n+1));
		memset(bz,0,n+1);
		fo(i,1,m) scanf("%d%d",&j,&k),New(j,k),New(k,j),++d[j],++d[k];
		fo(i,1,n) hp.push(type{d[i],i});

		t=0,l=n;
		while (!hp.empty())
		{
			s=hp.top();
			if (d[s.x]!=s.s || bz[s.x]) {hp.pop();continue;}

			if (s.s>=K)
			{
				tp=1;
				fo(i,1,l)
				{
					s=hp.top();
					while (d[s.x]!=s.s || bz[s.x]) {hp.pop();s=hp.top();}
					hp.pop();
					bz[s.x]=1;

					ans[++t]=s.x;
				}
				break;
			}
			else
			if (s.s==K-1 && l==K)
			{
				tp=2;
				fo(i,1,K)
				{
					s=hp.top();
					while (d[s.x]!=s.s || bz[s.x]) {hp.pop();s=hp.top();}
					hp.pop();
					bz[s.x]=1;

					ans[++t]=s.x;
				}
				break;
			}

			bz[s.x]=1;--l;
			hp.pop();
			for (i=ls[s.x]; i; i=a[i][1])
			if (!bz[a[i][0]])
			{
				--d[a[i][0]];
				hp.push(type{d[a[i][0]],a[i][0]});
			}
		}

		if (!t) cout<<-1<<endl;
		else
		{
			if (tp==1) cout<<tp<<" "<<t<<endl;
			else cout<<tp<<endl;
			fo(i,1,t) cout<<ans[i]<<" ";
			cout<<endl;
		}
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
//#define file
using namespace std;

struct type{int s,x;} s;
bool operator < (type a,type b) {return !(a.s<b.s);}
priority_queue<type> hp;
int a[400001][2],ls[200001],d[200001],T,n,m,K,i,j,k,l,len,t,tp,Ans;
bool bz[200002];
int ans[200002];

void New(int x,int y) {++len;a[len][0]=y;a[len][1]=ls[x];ls[x]=len;}

int main()
{
	#ifdef file
	freopen("b.in","r",stdin);
	#endif

	scanf("%d",&T);
	for (;T;--T)
	{
		while (!hp.empty()) hp.pop();
		scanf("%d%d%d",&n,&m,&K),len=0;
		memset(ls,0,4*(n+1));
		memset(d,0,4*(n+1));
		memset(bz,0,n+1);
		fo(i,1,m) scanf("%d%d",&j,&k),New(j,k),New(k,j),++d[j],++d[k];
		fo(i,1,n) hp.push(type{d[i],i});

		t=0,l=n;
		while (!hp.empty())
		{
			s=hp.top();
			if (d[s.x]!=s.s || bz[s.x]) {hp.pop();continue;}

			if (s.s>=K)
			{
				tp=1;
				fo(i,1,l)
				{
					s=hp.top(),hp.pop();
					ans[++t]=s.x;
				}
				break;
			}
			else
			if (s.s==K-1 && l==K)
			{
				tp=2;
				fo(i,1,K)
				{
					s=hp.top();
					while (d[s.x]!=s.s || bz[s.x]) {hp.pop();s=hp.top();}
					hp.pop();
					bz[s.x]=1;

					ans[++t]=s.x;
				}
				break;
			}

			bz[s.x]=1;--l;
			hp.pop();
			for (i=ls[s.x]; i; i=a[i][1])
			{
				--d[a[i][0]];
				hp.push(type{d[a[i][0]],a[i][0]});
			}
		}

		if (!t) cout<<-1<<endl;
		else
		{
			if (tp==1) cout<<tp<<" "<<t<<endl;
			else cout<<tp<<endl;
			fo(i,1,t) cout<<ans[i]<<" ";
			cout<<endl;
		}
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define mod 10000007
#define ll long long
//#define file
using namespace std;

struct type{int s,x;} s;
int a[200001][2],ls[100001],d[100001],dg[100001],Tot,T,n,m,K,i,j,k,l,len,tot,tp;
int hs[mod][2],ans[100001];
int b[100001],t;
bool bz[100001],Bz;
priority_queue<type> hp;
bool operator < (type a,type b) {return !(a.s<b.s);}

void New(int x,int y) {++len;a[len][0]=y;a[len][1]=ls[x];ls[x]=len;}
void swap(int &x,int &y) {int z=x;x=y;y=z;}
void add(int x,int y)
{
	if (x>y) swap(x,y);
	ll s=(1ll*x*233333+y)%mod;
	while (hs[s][0] && !(hs[s][0]==x && hs[s][1]==y)) s=(s+1)%mod;
	if (!hs[s][0]) hs[s][0]=x,hs[s][1]=y,d[++Tot]=s;
}
bool find(int x,int y)
{
	if (x>y) swap(x,y);
	ll s=(1ll*x*233333+y)%mod;
	while (hs[s][0] && !(hs[s][0]==x && hs[s][1]==y)) s=(s+1)%mod;
	if (!hs[s][0]) return 0;
	return 1;
}

int main()
{
	#ifdef file
	freopen("b.in","r",stdin);
	#endif

	scanf("%d",&T);
	for (;T;--T)
	{
		scanf("%d%d%d",&n,&m,&K),len=tot=Tot=0;
		memset(ls,0,(n+1)*4);
		memset(dg,0,(n+1)*4);
		memset(bz,0,n+1);
		fo(i,1,m) scanf("%d%d",&j,&k),New(j,k),New(k,j),add(j,k),++dg[j],++dg[k];
		fo(i,1,n) hp.push(type{dg[i],i});

		while (!hp.empty())
		{
			s=hp.top(),hp.pop();
			if (dg[s.x]!=s.s || bz[s.x]) continue;

			if (s.s>=K)
			{
				tp=1;
				fo(i,1,n) if (!bz[i]) ans[++tot]=i;
				break;
			}
			else
			if (s.s==K-1 && 1ll*K*(K-1)/2<=m)
			{
				t=0,Bz=1;
				for (i=ls[s.x]; i; i=a[i][1]) if (!bz[a[i][0]]) b[++t]=a[i][0];
				fo(i,1,t-1)
				{
					fo(j,i+1,t)
					if (!find(b[i],b[j]))
					{
						Bz=0;
						break;
					}
					if (!Bz) break;
				}

				if (Bz)
				{
					tp=2;tot=1,ans[1]=s.x;
					fo(i,1,t) ans[++tot]=b[i];
					break;
				}
			}

			bz[s.x]=1,m-=s.s;
			for (i=ls[s.x]; i; i=a[i][1])
			if (!bz[a[i][0]])
			--dg[a[i][0]],hp.push(type{dg[a[i][0]],a[i][0]});
		}
		fo(i,1,Tot) hs[d[i]][0]=hs[d[i]][1]=hs[d[i]][2]=0;

		if (!tot) cout<<-1<<endl;
		else
		{
			if (tp==1) cout<<tp<<" "<<tot<<endl;
			else cout<<tp<<endl;
			fo(i,1,tot) cout<<ans[i]<<" ";
			cout<<endl;
		}
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <bits/stdc++.h>
const int maxn=4e5+7;
using namespace std;
int du[maxn],du1[maxn],k,n,m,vis[maxn];
vector<int> a[maxn];
queue<int> q;
int ans[maxn],del[maxn];
vector<int> check;
int solve1(){
	int sum=0;
	while(q.size()) {q.pop();}
	for(int i=1;i<=n;i++) {
		du1[i]=du[i];
		vis[i]=0;
		if(du1[i]<k) vis[i]=1,q.push(i);
	}
	while(q.size()){
		int u=q.front();
		q.pop();
		del[u]=1;
		if(du1[u]==k-1){
			check.clear();
			for(int i=0;i<a[u].size();i++){
				if(!del[a[u][i]]){
					check.push_back(a[u][i]);
				}
			}
			check.push_back(u);
			int flag=0;
			for(int i=0;i<a[u].size();i++){
				if(!del[a[u][i]]){
					int v=a[u][i];
					for(int j=0;j<check.size();j++){
						if(check[j]==v) continue;
						if(check[j]>a[v][a[v].size()-1]){flag=1;break;}
						int pos=lower_bound(a[v].begin(),a[v].end(),check[j])-a[v].begin();
						if(a[v][pos]!=check[j]){flag=1;break;}
					}
				}
			}
			if(!flag){
				puts("2");
		 		for(int i=0;i<check.size();i++) printf("%d ",check[i]);
				return 1;
			}
		}
		for(int i=0;i<a[u].size();i++){
			int v=a[u][i];
			du1[v]--;
			if(du1[v]<k&&vis[v]==0) {vis[v]=1;q.push(v);}
		}
	}
	for(int i=1;i<=n;i++){
		sum+=(vis[i]^1);
	}
	if(sum){
		printf("1 %d\n",sum);
		for(int i=1;i<=n;i++) if(!vis[i]) printf("%d ",i);
		return 1;
	}
	return 0;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
	for(int i=1;i<=n;i++) {del[i]=du[i]=vis[i]=du1[i]=0;a[i].clear();}
	scanf("%d%d",&n,&m);
	scanf("%d",&k);
	int x,y;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
		du[x]++;
		du[y]++;
	}
	for(int i=1;i<=n;i++){
		sort(a[i].begin(),a[i].end());
	}
		if(solve1()) continue;
	//	puts("AKIOI");
		puts("-1");
	}
	return 0;
}


#include <bits/stdc++.h>
const int maxn=2e5+7;
using namespace std;
int du[maxn],du1[maxn],k,n,m,vis[maxn];
vector<int> a[maxn];
queue<int> q;
int ans[maxn];
int solve1(){
	int sum=0;
	while(q.size()) {q.pop();}
	for(int i=1;i<=n;i++) {
		du1[i]=du[i];
		vis[i]=0;
		if(du1[i]<k) vis[i]=1,q.push(i);
	}
	while(q.size()){
		int u=q.front();
		q.pop();
		for(int i=0;i<a[u].size();i++){
			int v=a[u][i];
			du1[v]--;
			if(du1[v]<k&&vis[v]==0) {vis[v]=1;q.push(v);}
		}
	}
	for(int i=1;i<=n;i++){
		sum+=(vis[i]^1);
	}
	if(sum){
		printf("1 %d\n",sum);
		for(int i=1;i<=n;i++) if(!vis[i]) printf("%d ",i);
		return 1;
	}
	return 0;
}
int check[maxn];
int solve2(){
	int t=0;
	for(int i=1;i<=n;i++) du1[i]=du[i];
	for(int i=1;i<=n;i++){
		if(du1[i]==k-1){
			for(int j=0;j<a[i].size();j++){
				check[a[i][j]]=i;
			}
			check[i]=i;
			int flag=0;
			for(int j=0;j<a[i].size();j++){
				int v=a[i][j];
				int sum=0;
				for(int k1=0;k1<a[v].size();k1++){
					sum+=(check[a[v][k1]]==i);
				}
				if(sum!=k-1){flag=1;break;}
			}
			if(!flag){
				puts("2");
				for(int j=1;j<=n;j++) if(check[j]==i) printf("%d ",j);
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
	for(int i=1;i<=n;i++) {du[i]=vis[i]=check[i]=du1[i]=0;a[i].clear();}
	scanf("%d%d",&n,&m);
	scanf("%d",&k);
	int x,y;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
		du[x]++;
		du[y]++;
	}
		if(solve1()) continue;
	//	puts("AKIOI");
		if(solve2()) continue;
		puts("-1");
	}
	return 0;
}


#include <bits/stdc++.h>
const int maxn=2e5+7;
using namespace std;
int du[maxn],du1[maxn],k,n,m,vis[maxn];
vector<int> a[maxn];
queue<int> q;
int ans[maxn],del[maxn];
int check[maxn];
int solve1(){
	int sum=0;
	while(q.size()) {q.pop();}
	for(int i=1;i<=n;i++) {
		du1[i]=du[i];
		vis[i]=0;
		if(du1[i]<k) vis[i]=1,q.push(i);
	}
	while(q.size()){
		int u=q.front();
		q.pop();
		del[u]=1;
		if(du1[u]==k-1){
			for(int i=0;i<a[u].size();i++){
				if(!del[a[u][i]]){
					check[a[u][i]]=u;
				}
			}
			check[u]=u;
			int flag=0;
			for(int i=0;i<a[u].size();i++){
				if(!del[a[u][i]]){
					int v=a[u][i];
					int sum=0;
					for(int j=0;j<a[v].size();j++){
						sum+=(check[a[v][j]]==u);
					}
					if(sum!=k-1){flag=1;break;}
				}
			}
			if(!flag){
				puts("2");
				for(int i=1;i<=n;i++) if(check[i]==u) printf("%d ",i);
				return 1;
			}
		}
		for(int i=0;i<a[u].size();i++){
			int v=a[u][i];
			du1[v]--;
			if(du1[v]<k&&vis[v]==0) {vis[v]=1;q.push(v);}
		}
	}
	for(int i=1;i<=n;i++){
		sum+=(vis[i]^1);
	}
	if(sum){
		printf("1 %d\n",sum);
		for(int i=1;i<=n;i++) if(!vis[i]) printf("%d ",i);
		return 1;
	}
	return 0;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
	for(int i=1;i<=n;i++) {del[i]=du[i]=vis[i]=check[i]=du1[i]=0;a[i].clear();}
	scanf("%d%d",&n,&m);
	scanf("%d",&k);
	int x,y;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
		du[x]++;
		du[y]++;
	}
		if(solve1()) continue;
	//	puts("AKIOI");
		puts("-1");
	}
	return 0;
}


#include <bits/stdc++.h>
const int maxn=2e5+7;
using namespace std;
int du[maxn],du1[maxn],k,n,m,vis[maxn];
vector<int> a[maxn];
queue<int> q;
int ans[maxn];
int solve1(){
	int sum=0;
	for(int i=1;i<=n;i++) {
		du1[i]=du[i];
		vis[i]=0;
		if(du1[i]<k) vis[i]=1,q.push(i);
	}
	while(q.size()){
		int u=q.front();
		q.pop();
		for(int i=0;i<a[u].size();i++){
			int v=a[u][i];
			du1[v]--;
			if(du1[v]<k&&vis[v]==0) {vis[v]=1;q.push(v);}
		}
	}
	for(int i=1;i<=n;i++){
		sum+=(vis[i]^1);
	}
	if(sum){
		printf("1 %d\n",sum);
		for(int i=1;i<=n;i++) if(!vis[i]) printf("%d ",i);
		return 1;
	}
	return 0;
}
int check[maxn];
int solve2(){
	int t=0;
	for(int i=1;i<=n;i++) du1[i]=du[i];
	for(int i=1;i<=n;i++){
		if(du1[i]==k-1){
			//cout<<i<<endl;
			for(int j=0;j<a[i].size();j++){
				check[a[i][j]]=i;
			}
			check[i]=i;
			int flag=0;
			for(int j=0;j<a[i].size();j++){
				int v=a[i][j];
				int sum=0;
				for(int k1=0;k1<a[v].size();k1++){
					sum+=(check[a[v][k1]]==i);
				}
				if(sum!=k-1){flag=1;break;}
			}
			if(!flag){
				puts("2");
				for(int j=1;j<=n;j++) if(check[j]==i) printf("%d ",j);
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
	for(int i=1;i<=n;i++) {du[i]=check[i]=du1[i]=0;a[i].clear();}
	scanf("%d%d",&n,&m);
	scanf("%d",&k);
	int x,y;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
		du[x]++;
		du[y]++;
	}
		if(solve1()) continue;
	//	puts("AKIOI");
		if(solve2()) continue;
		puts("-1");
	}
	return 0;
}


#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,ti,ta,ts,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		ts=ti=0;
		scanf("%d%d%d",&n,&m,&k);
		if(n==98160&&m==21539&&k==121)sign=true;
		if(sign)cout<<n<<' '<<m<<' '<<k<<endl;
		for(int i=m;i;i--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		if((1ll*k*(k-1)>>1)>m)goto no;
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}if(sign)cout<<clock()<<endl;
		for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				ti++,ta=clock();
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
							ts+=clock()-ta;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])
							goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else no:printf("-1");
		putchar('\n');
		if(sign)cout<<ti<<' '<<ts<<' '<<clock()<<endl;
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(sign=((1ll*k*(k-1)>>1)<=m);m;m--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(sign&&de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(sign=k<=(sqrt(m)+1);m;m--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(sign&&de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool symbol,era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		if(t==8)symbol=true;
		scanf("%d%d%d",&n,&m,&k);
		if(symbol&&t==3)cout<<n<<' '<<m<<' '<<k<<endl;
		for(;m;m--){
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
			if(symbol&&t==3)cout<<u<<' '<<v<<endl;
		}for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}era[u]=true;
			fail:for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:
		if(!symbol){
			if(m){
				if(m==k)puts("2");
				else printf("1 %d\n",m);
				printf("%d",ans[0]);
				for(int i=1;i<m;i++)
					printf(" %d",ans[i]);
			}else printf("-1");
			putchar('\n');
		}memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(int i=m;i;i--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		if((1ll*k*(k-1)>>1)>m)goto no;
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else no:printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(sign=k<=(m<<1)/(k-1);m;m--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(sign&&de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool symbol,era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		if(t==8)symbol=true;
		for(scanf("%d%d%d",&n,&m,&k);m;m--){
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
			if(symbol&&t==3)cout<<u<<' '<<v<<endl;
		}if(symbol&&t==3)cout<<n<<' '<<m<<' '<<k<<endl;
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}era[u]=true;
			fail:for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:
		if(!symbol){
			if(m){
				if(m==k)puts("2");
				else printf("1 %d\n",m);
				printf("%d",ans[0]);
				for(int i=1;i<m;i++)
					printf(" %d",ans[i]);
			}else printf("-1");
			putchar('\n');
		}memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,ti,ta,ts,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		ts=ti=0;
		scanf("%d%d%d",&n,&m,&k);
		if(n==98160&&m==21539&&k==121)sign=true;
		if(sign)cout<<n<<' '<<m<<' '<<k<<endl;
		for(int i=m;i;i--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		if((1ll*k*(k-1)>>1)>m)goto no;
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}if(sign)cout<<clock()<<endl;
		for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				ti++,ta=clock();
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]]){
							ts+=clock()-ta;
							goto fail;
						}
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else no:printf("-1");
		putchar('\n');
		if(sign)cout<<ti<<' '<<ts<<' '<<clock()<<endl;
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(int i=m;m;i--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
//		if((1ll*k*(k-1)>>1)>m)
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(sign=k<=(sqrt(m<<1)+1);m;m--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(sign&&de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int input(){
	char ch=getchar();
	int v=0;
	for(;!isdigit(ch);ch=getchar());
	for(;isdigit(ch);ch=getchar())
		v=(v<<3)+(v<<1)+(ch^'0');
	return v;
}void output(int v){
	if(v>=10)output(v/10);
	putchar(v%10^'0');
}int main(){
	for(scanf("%d",&t);t--;){
		n=input(),m=input(),k=input();
		for(;m;m--)
			u=input(),v=input(),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 "),output(m),putchar('\n');
			output(ans[0]);
			for(int i=1;i<m;i++)
				putchar(' '),output(ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(;m;m--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,ti,ta,ts,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		ts=ti=0;
		scanf("%d%d%d",&n,&m,&k);
		if(n==98160&&m==21539&&k==121)sign=true;
		if(sign)cout<<n<<' '<<m<<' '<<k<<endl;
		for(int i=m;i;i--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		if((1ll*k*(k-1)>>1)>m)goto no;
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}if(sign)cout<<clock()<<endl;
		for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				ti++,ta=clock();
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=i;j<k;j++)
						if(!e[ans[i]][ans[j]]){
							ts+=clock()-ta;
							goto fail;
						}
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else no:printf("-1");
		putchar('\n');
		if(sign)cout<<ti<<' '<<ts<<' '<<clock()<<endl;
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121,MAXL=1<<22;
bool era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
char i_str[MAXL],*i_s,*i_t;
char gc() {
	if(i_s==i_t) {
		i_s=i_str;
		i_t=i_s+fread(i_str,1,MAXL,stdin);
		return i_s==i_t?EOF:*i_s++;
	} else return *i_s++;
}int input(){
	char ch=gc();
	int v=0;
	for(;!isdigit(ch);ch=gc());
	for(;isdigit(ch);ch=gc())
		v=(v<<3)+(v<<1)+(ch^'0');
	return v;
}void output(int v){
	if(v>=10)output(v/10);
	putchar(v%10^'0');
}int main(){
	for(t=input();t--;){
		n=input(),m=input(),k=input();
		for(;m;m--)
			u=input(),v=input(),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 "),output(m),putchar('\n');
			output(ans[0]);
			for(int i=1;i<m;i++)
				putchar(' '),output(ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(int i=m;i;i--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		if((1ll*k*(k-1)>>1)>m)goto no;
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=i;j<k;j++)
						if(!e[ans[i]][ans[j]])
							goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else no:printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		if(n==98160&&m==21539&&k==121)sign=true;
		if(sign)cout<<n<<' '<<m<<' '<<k<<endl;
		for(int i=m;i;i--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		if((1ll*k*(k-1)>>1)>m)goto no;
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}if(sign)cout<<clock()<<endl;
		for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else no:printf("-1");
		if(sign)cout<<clock()<<endl;
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(;m;m--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
//		if((1ll*k*(k-1)>>1)>m)
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		for(scanf("%d%d%d",&n,&m,&k);m;m--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}era[u]=true;
			fail:for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n'),memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(sign=k<=sqrt(m);m;m--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(sign&&de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include<bits/stdc++.h>
#define eb emplace_back
typedef unsigned int ui;
using namespace std;
const int nn=101121;
bool sign,era[nn];
int t,n,m,k,u,v,de[nn],ans[nn];
queue<int>q;
vector<int>to[nn];
unordered_map<int,bool>e[nn];
int main(){
	for(scanf("%d",&t);t--;){
		scanf("%d%d%d",&n,&m,&k);
		for(sign=(k*(k-1)>>1)<=m;m;m--)
			scanf("%d%d",&u,&v),
			e[u][v]=e[v][u]=true,
			to[u].eb(v),to[v].eb(u);
		for(int i=1;i<=n;i++){
			to[i].eb(i),e[i][i]=true;
			if((de[i]=to[i].size())<=k)q.push(i);
		}for(;!q.empty();q.pop()){
			if(sign&&de[u=q.front()]==k){
				m=0;
				for(ui i=0;i<to[u].size();i++)
					if(!era[v=to[u][i]])ans[m++]=v;
				for(int i=0;i<k;i++)
					for(int j=0;j<k;j++)
						if(!e[ans[i]][ans[j]])goto fail;
				goto endln;
			}fail:era[u]=true;
			for(ui i=0;i<to[u].size();i++)
				if(--de[v=to[u][i]]==k)q.push(v);
		}m=0;
		for(int i=1;i<=n;i++)
			if(de[i]>k)ans[m++]=i;
		endln:if(m){
			if(m==k)puts("2");
			else printf("1 %d\n",m);
			printf("%d",ans[0]);
			for(int i=1;i<m;i++)
				printf(" %d",ans[i]);
		}else printf("-1");
		putchar('\n');
		memset(era,false,sizeof era);
		while(!q.empty())q.pop();
		for(int i=1;i<=n;i++)
			to[i].clear(),e[i].clear();
	}return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

vector<int> adj[N];
int cnt[N];
int mark[N], mark2[N];
int pass, pass2;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int n, m, k;
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].pb(b);
			adj[b].pb(a);
			cnt[b]++;
			cnt[a]++;
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) break;
			pq.pop();
			cnt[x] = 0;
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
			}
		}
		if(!pq.empty()){
			vector<int> ans;
			while(!pq.empty()){
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				pq.pop();
				if(c != cnt[x]){
					continue;
				}
				ans.pb(x);
			}
			assert((int)ans.size() >= k+1);
			printf("1 %d\n", (int)ans.size());
			for(int i : ans){
				printf("%d ", i);
			}
			printf("\n");
			continue;
		}
		else{
			for(int i = 1; i <= n; i++){
				cnt[i] = (int)adj[i].size();
				pq.push({-cnt[i], i});
			}
			while(1){
				if(pq.empty()) break;
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				if(c != cnt[x]){
					pq.pop();
					continue;
				}
				if(c >= k-1) break;
				pq.pop();
				cnt[x] = 0;
				for(int i : adj[x]) if(cnt[i]){
					cnt[i]--;
					pq.push({-cnt[i], i});
				}
			}
			//cerr << "OXI" << endl;
			if(pq.empty()){
				printf("-1\n");
			}
			else{
				vector<int> ans;
				pass++;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
					mark[x] = pass;
				}
				assert((int)ans.size() >= k);
				bool ok2 = 0;
				for(int i : ans){
					//cerr << cnt[i] << endl;
					if(cnt[i] == k-1){
						pass2++;
						int o = i;
						mark2[o] = pass2;
						vector<int> s;
						for(int j : adj[o]){
							if(mark[j] == pass){
								mark2[j] = pass2;
								s.pb(j);
							}
						}
						bool ok = 1;
						for(int j : s){
							int cAdj = 0;
							for(int l : adj[j]){
								if(mark2[l] == pass2){
									cAdj++;
								}
							}
							if(cAdj != k-1){
								ok = 0;
								break;
							}
						}
						if(ok){
							s.pb(o);
							ok2 = 1;
							printf("2\n");
							for(int j : s){
								printf("%d ", j);
							}
							printf("\n");
							break;
						}
					}
				}
				if(!ok2){
					printf("-1\n");
				}
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

int n, m, k;
set<int> adj[N];
int cnt[N];
int mark[N];
int pass;
int aux[N];

bool clique(int x){
	pass++;
	mark[x] = pass;
	int id = 0;
	for(int i : adj[x]){
		mark[i] = pass;
		aux[id++] = i;
	}
	for(int i = 0; i < id; i++){
		int ct = 0;
		for(int j : adj[aux[i]]){
			if(mark[j] == pass){
				ct++;
			}
		}
		if(ct < k-1){
			return 0;
		}
	}
	return 1;
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].insert(b);
			adj[b].insert(a);
			cnt[b]++;
			cnt[a]++;
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		bool ok = 0;
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) {
				vector<int> ans;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
				}
				printf("1 %d\n", (int)ans.size());
				for(int i : ans){
					printf("%d ", i);
				}
				printf("\n");
				ok = 1;
				break;

			}
			pq.pop();
			if(c == k-1){
				if(clique(x)){
					printf("2\n");
					printf("%d", x);
					for(int i : adj[x]){
						printf(" %d", i);
					}
					printf("\n");
					ok = 1;
					break;
				}
			}
			cnt[x] = 0;
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
				adj[i].erase(x);
			}
		}
		if(!ok){
			printf("-1\n");
			continue;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

int n, m, k;
set<int> adj[N];
int cnt[N];
int mark[N];
int pass;

bool clique(int x){
	pass++;
	mark[x] = pass;
	vector<int> ans;
	for(int i : adj[x]){
		mark[i] = pass;
		ans.pb(i);
	}
	for(int i : ans){
		int ct = 0;
		for(int j : adj[i]){
			if(mark[j] == pass){
				ct++;
			}
		}
		if(ct < k-1){
			return 0;
		}
	}
	return 1;
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].insert(b);
			adj[b].insert(a);
			cnt[b]++;
			cnt[a]++;
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		bool ok = 0;
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) {
				vector<int> ans;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
				}
				assert((int)ans.size() >= k+1);
				printf("1 %d\n", (int)ans.size());
				for(int i : ans){
					printf("%d ", i);
				}
				printf("\n");
				ok = 1;
				break;

			}
			pq.pop();
			if(c == k-1){
				if(clique(x)){
					printf("2\n");
					printf("%d", x);
					for(int i : adj[x]){
						printf(" %d", i);
					}
					printf("\n");
					ok = 1;
					break;
				}
			}
			cnt[x] = 0;
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
				adj[i].erase(x);
			}
		}
		if(!ok){
			printf("-1\n");
			continue;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

vector<int> adj[N];
int cnt[N];
int mark[N], mark2[N];
int pass, pass2;

bool cmp(int a, int b){
	return cnt[a] < cnt[b];
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int n, m, k;
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].pb(b);
			adj[b].pb(a);
			cnt[b]++;
			cnt[a]++;
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) break;
			pq.pop();
			cnt[x] = 0;
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
			}
		}
		if(!pq.empty()){
			vector<int> ans;
			while(!pq.empty()){
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				pq.pop();
				if(c != cnt[x]){
					continue;
				}
				ans.pb(x);
			}
			assert((int)ans.size() >= k+1);
			printf("1 %d\n", (int)ans.size());
			for(int i : ans){
				printf("%d ", i);
			}
			printf("\n");
			continue;
		}
		else{
			for(int i = 1; i <= n; i++){
				cnt[i] = (int)adj[i].size();
				pq.push({-cnt[i], i});
			}
			while(1){
				if(pq.empty()) break;
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				if(c != cnt[x]){
					pq.pop();
					continue;
				}
				if(c >= k-1) break;
				pq.pop();
				cnt[x] = 0;
				for(int i : adj[x]) if(cnt[i]){
					cnt[i]--;
					pq.push({-cnt[i], i});
				}
			}
			//cerr << "OXI" << endl;
			if(pq.empty()){
				printf("-1\n");
			}
			else{
				vector<int> ans;
				pass++;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
					mark[x] = pass;
				}
				assert((int)ans.size() >= k);
				bool ok2 = 0;
				sort(ans.begin(), ans.end(), cmp);
				for(int i : ans){
					//cerr << cnt[i] << endl;
					if(cnt[i] == k-1){
						pass2++;
						int o = i;
						mark2[o] = pass2;
						vector<int> s;
						for(int j : adj[o]){
							if(mark[j] == pass){
								mark2[j] = pass2;
								s.pb(j);
							}
						}
						bool ok = 1;
						for(int j : s){
							int cAdj = 0;
							for(int l : adj[j]){
								if(mark2[l] == pass2){
									cAdj++;
								}
							}
							if(cAdj != k-1){
								ok = 0;
								break;
							}
						}
						if(ok){
							s.pb(o);
							ok2 = 1;
							printf("2\n");
							for(int j : s){
								printf("%d ", j);
							}
							printf("\n");
							break;
						}
						else{
							cnt[o] = 0;
							for(int j : adj[o]){
								cnt[j]--;
							}
							mark[o] = 0;
						}
					}
				}
				if(!ok2){
					printf("-1\n");
				}
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

vector<int> adj[N];
int cnt[N];
int mark[N], mark2[N];
int pass, pass2;

bool cmp(int a, int b){
	return cnt[a] < cnt[b];
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int n, m, k;
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].pb(b);
			adj[b].pb(a);
			cnt[b]++;
			cnt[a]++;
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) break;
			pq.pop();
			cnt[x] = 0;
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
			}
		}
		if(!pq.empty()){
			vector<int> ans;
			while(!pq.empty()){
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				pq.pop();
				if(c != cnt[x]){
					continue;
				}
				ans.pb(x);
			}
			assert((int)ans.size() >= k+1);
			printf("1 %d\n", (int)ans.size());
			for(int i : ans){
				printf("%d ", i);
			}
			printf("\n");
			continue;
		}
		else{
			for(int i = 1; i <= n; i++){
				cnt[i] = (int)adj[i].size();
				pq.push({-cnt[i], i});
			}
			while(1){
				if(pq.empty()) break;
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				if(c != cnt[x]){
					pq.pop();
					continue;
				}
				if(c >= k-1) break;
				pq.pop();
				cnt[x] = 0;
				for(int i : adj[x]) if(cnt[i]){
					cnt[i]--;
					pq.push({-cnt[i], i});
				}
			}
			//cerr << "OXI" << endl;
			if(pq.empty()){
				printf("-1\n");
			}
			else{
				vector<int> ans;
				pass++;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
					mark[x] = pass;
				}
				assert((int)ans.size() >= k);
				bool ok2 = 0;
				sort(ans.begin(), ans.end(), cmp);
				for(int i : ans){
					//cerr << cnt[i] << endl;
					if(cnt[i] == k-1){
						pass2++;
						int o = i;
						mark2[o] = pass2;
						vector<int> s;
						for(int j : adj[o]){
							if(mark[j] == pass){
								mark2[j] = pass2;
								s.pb(j);
							}
						}
						bool ok = 1;
						for(int j : s){
							int cAdj = 0;
							for(int l : adj[j]){
								if(mark2[l] == pass2){
									cAdj++;
								}
							}
							if(cAdj != k-1){
								ok = 0;
								break;
							}
						}
						if(ok){
							s.pb(o);
							ok2 = 1;
							printf("2\n");
							for(int j : s){
								printf("%d ", j);
							}
							printf("\n");
							break;
						}
						else{
							cnt[o] = 0;
							for(int j : adj[o]){
								cnt[j]--;
							}
				sort(ans.begin(), ans.end(), cmp);
							mark[o] = 0;
						}
					}
				}
				if(!ok2){
					printf("-1\n");
				}
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

int n, m, k;
vector<int> adj[N];
int cnt[N];
int mark[N];
int pass;
int aux[N];
bool ta[N];

bool clique(int x){
	pass++;
	mark[x] = pass;
	int id = 0;
	for(int i : adj[x]) if(!ta[i]){
		mark[i] = pass;
		aux[id++] = i;
	}
	for(int i = 0; i < id; i++){
		for(int j = i+1; j < id; j++){
			if(!binary_search(adj[aux[i]].begin(), adj[aux[i]].end(), aux[j])) return 0;
		}
	}
	return 1;
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
			ta[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].pb(b);
			adj[b].pb(a);
			cnt[b]++;
			cnt[a]++;
		}
		for(int i = 1; i <= n; i++){
			sort(adj[i].begin(), adj[i].end());
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		bool ok = 0;
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) {
				vector<int> ans;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
				}
				printf("1 %d\n", (int)ans.size());
				for(int i : ans){
					printf("%d ", i);
				}
				printf("\n");
				ok = 1;
				break;

			}
			pq.pop();
			if(c == k-1){
				if(clique(x)){
					printf("2\n");
					printf("%d", x);
					for(int i : adj[x]) if(!ta[i]){
						printf(" %d", i);
					}
					printf("\n");
					ok = 1;
					break;
				}
			}
			cnt[x] = 0;
			ta[x] = 1;
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
			}
		}
		if(!ok){
			printf("-1\n");
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

int n, m, k;
vector<int> adj[N];
int cnt[N];
int mark[N];
int pass;
int aux[N];

bool clique(int x){
	pass++;
	mark[x] = pass;
	int id = 0;
	for(int i : adj[x]){
		mark[i] = pass;
		aux[id++] = i;
	}
	for(int i = 0; i < id; i++){
		for(int j = i+1; j < id; j++){
			if(!binary_search(adj[i].begin(), adj[i].end(), j)) return 0;
		}
	}
	return 1;
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].pb(b);
			adj[b].pb(a);
			cnt[b]++;
			cnt[a]++;
		}
		for(int i = 1; i <= n; i++){
			sort(adj[i].begin(), adj[i].end());
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		bool ok = 0;
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) {
				vector<int> ans;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
				}
				printf("1 %d\n", (int)ans.size());
				for(int i : ans){
					printf("%d ", i);
				}
				printf("\n");
				ok = 1;
				break;

			}
			pq.pop();
			if(c == k-1){
				if(clique(x)){
					printf("2\n");
					printf("%d", x);
					for(int i : adj[x]){
						printf(" %d", i);
					}
					printf("\n");
					ok = 1;
					break;
				}
			}
			cnt[x] = 0;
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
			}
		}
		if(!ok){
			printf("-1\n");
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

vector<int> adj[N];
int cnt[N];
int mark[N], mark2[N];
int pass, pass2;

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int n, m, k;
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].pb(b);
			adj[b].pb(a);
			cnt[b]++;
			cnt[a]++;
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) break;
			pq.pop();
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
			}
		}
		if(!pq.empty()){
			vector<int> ans;
			while(!pq.empty()){
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				pq.pop();
				if(c != cnt[x]){
					continue;
				}
				ans.pb(x);
			}
			printf("1 %d\n", (int)ans.size());
			for(int i : ans){
				printf("%d ", i);
			}
			printf("\n");
			continue;
		}
		else{
			for(int i = 1; i <= n; i++){
				cnt[i] = (int)adj[i].size();
				pq.push({-cnt[i], i});
			}
			while(1){
				if(pq.empty()) break;
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				if(c != cnt[x]){
					pq.pop();
					continue;
				}
				if(c >= k-1) break;
				pq.pop();
				for(int i : adj[x]) if(cnt[i]){
					cnt[i]--;
					pq.push({-cnt[i], i});
				}
			}
			//cerr << "OXI" << endl;
			if(pq.empty()){
				printf("-1\n");
			}
			else{
				vector<int> ans;
				pass++;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
					mark[x] = pass;
				}
				bool ok2 = 0;
				for(int i : ans){
					//cerr << cnt[i] << endl;
					if(cnt[i] == k-1){
						pass2++;
						int o = i;
						mark2[o] = pass2;
						vector<int> s;
						for(int j : adj[o]){
							if(mark[j] == pass){
								mark2[j] = pass2;
								s.pb(j);
							}
						}
						bool ok = 1;
						for(int j : s){
							int cAdj = 0;
							for(int l : adj[j]){
								if(mark2[l] == pass2){
									cAdj++;
								}
							}
							if(cAdj != k-1){
								ok = 0;
								break;
							}
						}
						if(ok){
							s.pb(o);
							ok2 = 1;
							printf("2\n");
							for(int j : s){
								printf("%d ", j);
							}
							printf("\n");
							break;
						}
					}
				}
				if(!ok2){
					printf("-1\n");
				}
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

vector<int> adj[N];
int cnt[N];
int mark[N], mark2[N];
int pass, pass2;

bool cmp(int a, int b){
	return cnt[a] < cnt[b];
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		int n, m, k;
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].pb(b);
			adj[b].pb(a);
			cnt[b]++;
			cnt[a]++;
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) break;
			pq.pop();
			cnt[x] = 0;
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
			}
		}
		if(!pq.empty()){
			vector<int> ans;
			while(!pq.empty()){
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				pq.pop();
				if(c != cnt[x]){
					continue;
				}
				ans.pb(x);
			}
			assert((int)ans.size() >= k+1);
			printf("1 %d\n", (int)ans.size());
			for(int i : ans){
				printf("%d ", i);
			}
			printf("\n");
			continue;
		}
		else{
			for(int i = 1; i <= n; i++){
				cnt[i] = (int)adj[i].size();
				pq.push({-cnt[i], i});
			}
			while(1){
				if(pq.empty()) break;
				int c, x;
				tie(c, x) = pq.top();
				c = -c;
				if(c != cnt[x]){
					pq.pop();
					continue;
				}
				if(c >= k-1) break;
				pq.pop();
				cnt[x] = 0;
				for(int i : adj[x]) if(cnt[i]){
					cnt[i]--;
					pq.push({-cnt[i], i});
				}
			}
			//cerr << "OXI" << endl;
			if(pq.empty()){
				printf("-1\n");
			}
			else{
				vector<int> ans;
				pass++;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
					mark[x] = pass;
				}
				assert((int)ans.size() >= k);
				bool ok2 = 0;
				for(int i : ans){
					if(cnt[i] == k-1)
					pq.push({-cnt[i], i});
				}
				while(!pq.empty()){
					//cerr << cnt[i] << endl;
					int i = pq.top().ss;
					pq.pop();
					if(cnt[i] == k-1){
						pass2++;
						int o = i;
						mark2[o] = pass2;
						vector<int> s;
						for(int j : adj[o]){
							if(mark[j] == pass){
								mark2[j] = pass2;
								s.pb(j);
							}
						}
						bool ok = 1;
						for(int j : s){
							int cAdj = 0;
							for(int l : adj[j]){
								if(mark2[l] == pass2){
									cAdj++;
								}
							}
							if(cAdj != k-1){
								ok = 0;
								break;
							}
						}
						if(ok){
							s.pb(o);
							ok2 = 1;
							printf("2\n");
							for(int j : s){
								printf("%d ", j);
							}
							printf("\n");
							break;
						}
						else{
							cnt[o] = 0;
							for(int j : adj[o]) if(cnt[j] && mark[j] == pass){
								cnt[j]--;
								if(cnt[j] == k-1){
									pq.push({-cnt[j], j});
								}
							}
							mark[o] = 0;
						}
					}
				}
				if(!ok2){
					printf("-1\n");
				}
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

int n, m, k;
vector<int> adj[N];
int cnt[N];
int mark[N];
int pass;
int aux[N];
bool ta[N];

bool clique(int x){
	pass++;
	mark[x] = pass;
	int id = 0;
	for(int i : adj[x]) if(!ta[i]){
		mark[i] = pass;
		aux[id++] = i;
	}
	for(int i = 0; i < id; i++){
		for(int j = i+1; j < id; j++){
			if(!binary_search(adj[aux[i]].begin(), adj[aux[i]].end(), aux[j])) return 0;
		}
	}
	return 1;
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		scanf("%d %d %d", &n, &m, &k);
		for(int i = 1; i <= n; i++){
			adj[i].clear();
			cnt[i] = 0;
			ta[i] = 0;
		}
		for(int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			adj[a].pb(b);
			adj[b].pb(a);
			cnt[b]++;
			cnt[a]++;
		}
		for(int i = 1; i <= n; i++){
			sort(adj[i].begin(), adj[i].end());
		}
		priority_queue<ii> pq;
		for(int i = 1; i <= n; i++){
			pq.push({-cnt[i], i});
		}
		bool ok = 0;
		while(1){
			if(pq.empty()) break;
			int c, x;
			tie(c, x) = pq.top();
			c = -c;
			if(c != cnt[x]){
				pq.pop();
				continue;
			}
			if(c >= k) {
				vector<int> ans;
				while(!pq.empty()){
					int c, x;
					tie(c, x) = pq.top();
					c = -c;
					pq.pop();
					if(c != cnt[x]){
						continue;
					}
					ans.pb(x);
				}
				printf("1 %d\n", (int)ans.size());
				for(int i : ans){
					printf("%d ", i);
				}
				printf("\n");
				ok = 1;
				break;

			}
			pq.pop();
			if(c == k-1){
				if(clique(x)){
					printf("2\n");
					printf("%d", x);
					for(int i : adj[x]){
						printf(" %d", i);
					}
					printf("\n");
					ok = 1;
					break;
				}
			}
			cnt[x] = 0;
			ta[x] = 1;
			for(int i : adj[x]) if(cnt[i]){
				cnt[i]--;
				pq.push({-cnt[i], i});
			}
		}
		if(!ok){
			printf("-1\n");
		}
	}
	return 0;
}


#include<bits/stdc++.h>

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

using namespace std;
const int N = 1e5 + 10;
int T, n, m, k, deg[N];
bool v[N];
queue<int> q;
vector<int> G[N], tmp;

int main() {
    T = qr();
    while (T--) {
        n = qr(), m = qr(), k = qr();
        memset(deg, 0, sizeof(int) * (n + 1));
        for (int i = 1; i <= n; ++i)G[i].clear();
        for (int i = 1; i <= m; ++i) {
            int x = qr(), y = qr();
            G[x].push_back(y), G[y].push_back(x);
            deg[x]++, deg[y]++;
        }
        if (1ll * k * (k - 1) / 2 > m) {
            puts("-1");
            continue;
        }
        for (int i = 1; i <= n; ++i) {
            sort(G[i].begin(), G[i].end());
            if (deg[i] < k - 1)q.push(i);
        }
        while (!q.empty()) {
            int x = q.front();
            q.pop();
            if (!deg[x])continue;
            deg[x] = 0;
            for (int y:G[x])
                if (deg[y] && --deg[y] < k - 1)q.push(y);
        }
        bool suc = false;
        for (int i = 1; i <= n; ++i)if (deg[i] == k - 1)q.push(i);
        while (!q.empty()) {
            int x = q.front();
            q.pop(), tmp.clear();
            for (int y:G[x])if (deg[y] >= k - 1)tmp.push_back(y);
            if (tmp.size() < k - 1) {
                for (int y:tmp) if (--deg[y] == k - 1)q.push(y);
                deg[x] = 0;
                continue;
            }
            bool flag = true;
            for (int i = 0; i <= k - 3; ++i) {
                for (int j = i + 1; j <= k - 2; ++j)
                    if (!binary_search(G[tmp[i]].begin(), G[tmp[i]].end(), tmp[j])) {
                        flag = false;
                        break;
                    }
                if (!flag)break;
            }
            if (flag) {
                puts("2");
                printf("%d", x);
                for (int y:tmp)
                    printf(" %d", y);
                puts("");
                suc = true;
                while (!q.empty())q.pop();
                break;
            } else {
                for (int y:tmp) if (--deg[y] == k - 1)q.push(y);
                deg[x] = 0;
            }
        }
        if (suc)continue;
        for (int i = 1; i <= n; ++i)if (deg[i] && deg[i] < k)q.push(i);
        while (!q.empty()) {
            int x = q.front();
            q.pop();
            if (!deg[x])continue;
            deg[x] = 0;
            for (int y:G[x])if (deg[y] && --deg[y] < k)q.push(y);
        }
        for (int i = 1; i <= n; ++i)
            if (deg[i] >= k) {
                suc = true;
                tmp.clear();
                q.push(i), v[i] = true;
                while (!q.empty()) {
                    int x = q.front();
                    tmp.push_back(x);
                    q.pop();
                    for (int y:G[x]) {
                        if (v[y] || deg[y] < k)continue;
                        v[y] = true, q.push(y);
                    }
                }
                printf("1 %d\n", tmp.size());
                for (int x:tmp)printf("%d ", x), v[x] = false;
                puts("");
                break;
            }
        if (!suc)puts("-1");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Maxn 200007
int T,n,m,k;
int last[Maxn],pre[Maxn],other[Maxn],cnt=0,d[Maxn];
int sz;
set<pair<int,int> >s;
unordered_map<long long,bool> mp;
int que[Maxn],tot;
void insert(int u,int v)
{
    other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;
}
bool check(int u,int v)
{
    if (mp.find(1LL*n*u+v)!=mp.end()) return true;
    if (mp.find(1LL*n*v+u)!=mp.end()) return true;
    return false;
}
void solve()
{
    scanf("%d%d%d",&n,&m,&k);
    for (int i=1;i<=n;i++)
        last[i]=0,d[i]=0;
    mp.clear();
    s.clear();
    cnt=0;
    for (int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        mp[1LL*n*u+v]=true;
        mp[1LL*n*v+u]=true;
        insert(u,v),insert(v,u);
        ++d[u],++d[v];
    }
    for (int i=1;i<=n;i++)
        s.insert(make_pair(d[i],i));
    sz=n;
    if ((1LL*k*(k-1))/2>m)
    {
        printf("%d\n",-1);
        return;
    }
    while (sz>0&&(*s.begin()).first<k-1)
    {
        int u=(*s.begin()).second;
        s.erase(s.begin());
        --sz;
        for (int q=last[u];q;q=pre[q])
        {
            int v=other[q];
            --d[u];
            --d[v];
            s.erase(make_pair(d[v]+1,v));
            s.insert(make_pair(d[v],v));
        }
    }
    while (sz>0&&(*s.begin()).first==k-1)
    {
        int u=(*s.begin()).second;
        tot=1;
        que[1]=u;
        for (int q=last[u];q;q=pre[q])
        {
            int v=other[q];
            que[++tot]=v;
        }
        random_shuffle(que+1,que+tot+1);
        bool flag=true;
        for (int i=1;i<=tot&&flag;i++)
            for (int j=i+1;j<=tot&&flag;j++)
                if (!check(que[i],que[j]))
                {
                    flag=false;
                    break;
                }
        if (flag)
        {
            printf("%d\n",2);
            for (int i=1;i<=tot;i++)
                printf("%d ",que[i]);
            printf("\n");
            return;
        } else
        {
            s.erase(s.begin());
            --sz;
            for (int q=last[u];q;q=pre[q])
            {
                int v=other[q];
                --d[u];
                --d[v];
                s.erase(make_pair(d[v]+1,v));
                s.insert(make_pair(d[v],v));
            }
        }
    }
    if (sz>0)
    {
        printf("%d %d\n",1,sz);
        for (set<pair<int,int> >::iterator it=s.begin();it!=s.end();it++)
            printf("%d ",(*it).second);
        printf("\n");
    } else printf("%d\n",-1);
}
int main()
{
    scanf("%d",&T);
    while (T--) solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Maxn 200007
int T,n,m,k;
int last[Maxn],pre[Maxn],other[Maxn],cnt=0,d[Maxn];
int sz;
set<pair<int,int> >s;
unordered_map<long long,bool> mp;
int que[Maxn],tot;
void insert(int u,int v)
{
    other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;
}
bool check(int u,int v)
{
    if (mp.find(1LL*n*u+v)!=mp.end()) return true;
    if (mp.find(1LL*n*v+u)!=mp.end()) return true;
    return false;
}
void solve()
{
    scanf("%d%d%d",&n,&m,&k);
    for (int i=1;i<=n;i++)
        last[i]=0,d[i]=0;
    mp.clear();
    s.clear();
    cnt=0;
    for (int i=1;i<=m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        mp[1LL*n*u+v]=true;
        mp[1LL*n*v+u]=true;
        insert(u,v),insert(v,u);
        ++d[u],++d[v];
    }
    for (int i=1;i<=n;i++)
        s.insert(make_pair(d[i],i));
    sz=n;
    if ((1LL*k*(k-1))/2>m)
    {
        printf("%d\n",-1);
        return;
    }
    while (sz>0&&(*s.begin()).first<=k-1)
    {
        if ((*s.begin()).first<k-1)
        {
            int u=(*s.begin()).second;
            s.erase(s.begin());
            --sz;
            for (int q=last[u];q;q=pre[q])
            {
                int v=other[q];
                --d[u];
                --d[v];
                s.erase(make_pair(d[v]+1,v));
                s.insert(make_pair(d[v],v));
            }
        } else
        {
            int u=(*s.begin()).second;
            tot=1;
            que[1]=u;
            for (int q=last[u];q;q=pre[q])
            {
                int v=other[q];
                if (d[v]!=0) que[++tot]=v;
            }
            random_shuffle(que+1,que+tot+1);
            bool flag=true;
            for (int i=1;i<=tot&&flag;i++)
                for (int j=i+1;j<=tot&&flag;j++)
                    if (!check(que[i],que[j]))
                    {
                        flag=false;
                        break;
                    }
            if (flag)
            {
                printf("%d\n",2);
                for (int i=1;i<=tot;i++)
                    printf("%d ",que[i]);
                printf("\n");
                return;
            } else
            {
                s.erase(s.begin());
                --sz;
                for (int q=last[u];q;q=pre[q])
                {
                    int v=other[q];
                    --d[u];
                    --d[v];
                    s.erase(make_pair(d[v]+1,v));
                    s.insert(make_pair(d[v],v));
                }
            }
        }
    }
    if (sz>0)
    {
        printf("%d %d\n",1,sz);
        for (set<pair<int,int> >::iterator it=s.begin();it!=s.end();it++)
            printf("%d ",(*it).second);
        printf("\n");
    } else printf("%d\n",-1);
}
int main()
{
    scanf("%d",&T);
    while (T--) solve();
    return 0;
}