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
#include<bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<=(e);i++)
#define FORD(i,s,e) for(int i=(s);i>=(e);i--)
#define ALL(k) (k).begin(),(k).end()
#define e1 first 
#define e2 second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> PIP;
const int MAXN=200111;

vector<int> kraw[MAXN];
PII kr[MAXN];
int deg[MAXN];
int usu[MAXN];
int fu[MAXN];
void ustaw(int n){
	FOR(i,1,n) fu[i]=-1;
}
int find(int v){
	if(fu[v]<0) return v;
	fu[v]=find(fu[v]);
	return fu[v];
}
int unia(int a,int b){
	int aa=find(a),bb=find(b);
	if(aa==bb) return 0;
	if(fu[aa]>fu[bb]) swap(aa,bb);
	fu[aa]+=fu[bb];
	fu[bb]=aa;
	return 1;
}


main(){
	int n,m;scanf("%d%d",&n,&m);
	int d;scanf("%d",&d);
	FOR(i,1,m){
		int a,b;scanf("%d%d",&a,&b);
		kr[i]={a,b};
		kraw[a].PB(b);
		kraw[b].PB(a);
		deg[a]++,deg[b]++;
	}
	int sajz=n;
	priority_queue<PII> PQ;
	FOR(i,1,n) PQ.emplace(-deg[i],i);
	while(!PQ.empty()){
		int v=PQ.top().e2;
		int val=-PQ.top().e1;PQ.pop();
		if(usu[v]||val!=deg[v]) continue;
		if(val>=d) break;
		sajz--;
		usu[v]=1;
		for(auto b:kraw[v]){
			if(usu[b]) continue;
			deg[b]--;
			PQ.emplace(-deg[b],b);
		}
	}
	if(sajz==0) {puts("NIE");return 0;}
	ustaw(n);
	FOR(v,1,n){
		if(usu[v]) continue;
		for(auto b:kraw[v]){
			if(usu[b]) continue;
			unia(v,b);
		}
	}
	int najl=0;
	FOR(i,1,n){
		if(usu[i]) continue;
		if(fu[i]<fu[najl]) najl=i;
	}
	//puts("A");
	printf("%d\n",-fu[najl]);
	FOR(i,1,n) if(i==najl||fu[i]==najl) printf("%d ",i);
	puts("");
}