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
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector <int> graph[200010];
vector <int> answ;
vector <int> answer;
unsigned int n, m, d, a, b;
bool odw[200010];

void deleteNeig(int v) {
	graph[v].clear();
	for(unsigned int i = 1; i <=n; i++) {
		for(unsigned int j = 0; j < graph[i].size(); j++) {
			if(graph[i][j] == v) {
				graph[i].erase(graph[i].begin() + j);
				break;
			}
		} 
	}
}
void DFS(int v) {
	odw[v] = true;
	answ.push_back(v);
	for(unsigned int i = 0; i < graph[v].size(); i++) {
		if(!odw[graph[v][i]])
			DFS(graph[v][i]);
	}
	
}

int main() {
	scanf("%d%d%d", &n, &m, &d);
	for(unsigned int i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	bool change = true;
	while(change) {
		change = false;
		for(unsigned int i = 1; i <= n ;i++) {
			if(graph[i].size() > 0 && graph[i].size() < d) {
				deleteNeig(i);
				change = true;
			} 
		}
	}
	for(unsigned int i = 1; i <= n; i++) {
		if(!odw[i] && graph[i].size() > 0) {
			answ.clear();
			DFS(i);
			if(answ.size() > answer.size()) {
				answer = answ;
				answ.clear();
			}
		}
	}
	if(answer.size() == 0)
		printf("NIE\n");
	else {
		sort(answer.begin(), answer.end());
		printf("%lu\n", answer.size());
		for(unsigned int i = 0; i < answer.size(); i++)
			printf("%d ", answer[i]);
	}
		
	return 0;
}