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
#include<bits/stdc++.h>

using namespace std; 

const int mx = 200005; 

int s[mx], gru[mx], k[mx];  
vector<int>G[mx]; 
int g; 
bool vis[mx], ba[mx]; 

void dfs ( int v ) { 
	vis[v] = true; 
	k[v] = g; 
	gru[g]++; 
	for ( int i = 0; i < G[v].size(); i++ ) { 
		int u = G[v][i]; 
		if ( !vis[u] && !ba[u] ) 
			dfs(u); 
	}
}


int main () { 
	int n, m, d; 
	scanf("%d%d%d",&n,&m,&d); 
	for ( int i = 0; i < m; i++ ) { 
		int a, b; 
		scanf("%d%d",&a,&b); 
		G[a].push_back(b); 
		G[b].push_back(a); 
		s[a]++; 
		s[b]++; 
	}
	queue<int>p; 
	for ( int i = 1; i <= n; i++ ) 
		if ( s[i] < d ) 
			p.push(i);

	while ( !p.empty() ) { 
		int a; 
		a = p.front(); 
		p.pop();
		ba[a] = true; 
		for ( int i = 0; i < G[a].size(); i++ ) { 
			int u = G[a][i]; 
			s[u]--; 
			if ( s[u] < d && !ba[u] )  
				p.push(u); 
		}
	}
	int w = 0;
	g = 0; 
	for ( int i = 1; i <= n; i++ ) 
		if ( !ba[i] && !vis[i] ) { 
			g++; 
			dfs(i);
		}
	int l = 0; 
	for ( int i = 1; i <= n; i++ ) { 
		if ( gru[i] > l ) { 
			l = gru[i]; 
			w = i; 
		}
	}
	if ( w == 0 ) 
		puts("NIE"); 
	else {  
		printf("%d\n",gru[w]);
		for ( int i = 1; i <= n; i++ ) { 
			if ( k[i] == w ) 
				printf("%d ",i); 
		}
	}
}