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
#include<bits/stdc++.h>
#define PII pair<int,int>
#define f first
#define s second
#define VI vector<int>
#define LL long long
#define MP make_pair
#define LD long double
#define PB push_back
#define ALL(V) V.begin(),V.end()
#define abs(x) max((x),-(x))
#define PDD pair<LD,LD> 
#define VPII vector< PII > 
#define siz(V) ((int)V.size())
#define FOR(x, b, e)  for(int x=b;x<=(e);x++)
#define FORD(x, b, e) for(int x=b;x>=(e);x--)
#define REP(x, n)     for(int x=0;x<(n);x++)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
using namespace std;
int n,a,b,c,d,m;
const int MXN=2e5+5;
int siz[MXN];
VI V[MXN];
int odw[MXN];
int SIZ;
void dfs(int x)
	{
	if(odw[x]||siz[x]<d)return;
	SIZ++;
	odw[x]=1;
	REP(i,V[x].size())
		{
		dfs(V[x][i]);
		}
	}
main()
{
scanf("%d%d%d",&n,&m,&d);
FOR(i,1,m)
	{
	scanf("%d%d",&a,&b);
	siz[a]++;
	siz[b]++;
	V[a].PB(b);
	V[b].PB(a);
	}
VI usu;
FOR(i,1,n)
	{
	if(siz[i]<d)
		{
		usu.PB(i);
		siz[i]=0;
		}
	}
while(usu.size())
	{
	int x=usu.back();
	usu.pop_back();
	siz[x]=0;
	REP(i,V[x].size())
		{
		int v=V[x][i];
		if(siz[v])
			{
			siz[v]--;
			if(siz[v]<d)
				{
				siz[v]=0;
				usu.PB(v);
				}
			}
		}
	}

PII res=MP(0,0);
FOR(i,1,n)
	{
	SIZ=0;
	dfs(i);
	maxi(res,MP(SIZ,i));
	}
if(res.f==0)
	{
	puts("NIE");
	return 0;
	}
FOR(i,1,n)odw[i]=0;
dfs(res.s);
printf("%d\n",res.f);
FOR(i,1,n)
	{
	if(odw[i])printf("%d ",i);
	}
}