1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define MX 200020
vector <int> v[MX];

int met[MX];
int u[MX];
int k[MX];
int d,KOL;
int w[MX];

void usun(int n){
	//printf("n=%d k[%d]=%d  d=%d\n",n,n,k[n],d);
	u[n]=1;
	int s=v[n].size();
	for(int i=0;i<s;++i){
	//	printf("%d   --%d\n",n,v[n][i]);
		--k[v[n][i]];
		if(k[v[n][i]]<d && u[v[n][i]]==0 ) {
	//		printf("%d -> %d bo k[%d]=%d\n",n,v[n][i],v[n][i],k[v[n][i]]);
			usun(v[n][i]);
		}
	}
}

int dfs(int n){
	met[n]=KOL;
	//printf("!");
	int s=v[n].size();
	int wyn=0;
	for(int i=0;i<s;++i){
		int b=v[n][i];
		if(u[b]==0 && met[b]==0){
			wyn+=dfs(b);
		}
	}
	return wyn+1;
}
int l=0;
void dfs2(int n){
	met[n]=0;
	int s=v[n].size();
	w[l]=n;++l;
	for(int i=0;i<s;++i){
		if(met[v[n][i]]==KOL){
			dfs2(v[n][i]);
		}
	}
}

int main(){
	int n,m;
	cin>>n>>m>>d;
	
	int i,j;
	int a,b;
	for(i=0;i<m;++i){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	for(i=1;i<=n;++i) k[i]=v[i].size();
	
//	printf("\n");
//	for(i=1;i<=n;++i)printf("k[%d]=%d  %d\n",i,k[i],u[i]);
//	printf("\n");
	
	for(i=1;i<=n;++i){
		if(k[i]<d && u[i]==0){
			usun(i);
		}
	}
	
//	for(i=1;i<=n;++i)printf("k[%d]=%d  %d\n",i,k[i],u[i]);
	
	int wyn,WYN=0;
	int index=0;
	for(i=1;i<=n;++i){
		wyn=0;
		if(met[i]==0&&u[i]==0){
			KOL=i;
			wyn=dfs(i);
	//		printf("wyn=%d\n",wyn);
			if(wyn>WYN){
				index=i;
				WYN=wyn;
			}
		}
	}
	if(WYN!=0)
	printf("%d\n",WYN);
	else{
		printf("NIE");
		return 0;
	}
	KOL=met[index];
	dfs2(index);
	
	/*w[0]=3 ;
	w[1]=2 ;
	w[2]=4 ;
	w[3]=1 ;
	w[4]=0 ;
	l=4;
	printf("TAB: ");
	for(i=0;i<=l;++i){
		printf("%d ",w[i]);
	}
	printf("\n");
	*/
	--l;
	sort(w,w+l+1);
	for(i=0;i<=l;++i){
		printf("%d ",w[i]);
	}
	
	
	
	
}