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
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const ll INF = 1e18+3;
#define maxn 200100
bool odw[maxn];
vector <int> v[maxn];
int n, m, d, a, b, size = 0;
int kraw[maxn], rem[maxn], NUM[maxn];
queue <int> q;
void bfs()
{
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		for (ui i=0; i<v[x].size(); ++i) 
		{
			int u = v[x][i];
			kraw[u]--;
			if (kraw[u] < d && !rem[u])
			{
				rem[u] = 1;
				q.push(u);
			}
		}
	}
}

void dfs(int x, int num)
{
	++size;
	odw[x] = 1;
	NUM[x] = num;
	for (ui i=0; i<v[x].size(); ++i)
		if (!odw[v[x][i]] && !rem[v[x][i]]) dfs(v[x][i], num);
}
int main()
{
	scanf("%d%d%d", &n, &m, &d);
	for (int i=1; i<=m; ++i)
	{
		scanf("%d%d", &a, &b);
		v[a].pb(b);
		v[b].pb(a);
	}
	for (int i=1; i<=n; ++i) kraw[i] = v[i].size();
	for (int i=1; i<=n; ++i) 
		if (kraw[i] < d) rem[i] = 1, q.push(i);
	bfs();

	int nr = 0;
	PII wyn = mp(-1, -1);
	for (int i=1; i<=n; ++i) 
	{
		if (!rem[i] && !odw[i]) 
		{
			size = 0;
			++nr;
			dfs(i, nr);
			if (size > wyn.e1) wyn = mp(size, nr);
		}
	}

	if (wyn.e1 == -1) OUT("NIE");
	printf("%d\n", wyn.e1);
	for (int i=1; i<=n; ++i)
	  if (wyn.e2 == NUM[i]) printf("%d ", i);
}