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
 97
 98
 99
100
101
102
#include <cstdio>
#include <set>
#include <queue>
using namespace std;
struct jp{
	vector<int>v;
};
jp t1[200111], t2[200111];
queue<int>q;
pair<int,int>drogi[200111];
int n, m, d, a, b, lol, siz[200111], numer[200111], pom, wyn, wynn;
bool odw[200111];
int main()
{
	scanf("%d%d%d", &n, &m, &d);
	for(int i=1; i<=m; i++)
	{
		scanf("%d%d", &a, &b);
		t1[a].v.push_back(b);
		t1[b].v.push_back(a);
		drogi[i]=make_pair(a, b);
	}
	for(int i=1; i<=n; i++)
	{
		siz[i]=t1[i].v.size();
		if(siz[i]<d){q.push(i); odw[i]=true;}
	}
	while(!q.empty())
	{
		lol=q.front();
		q.pop();
		siz[lol]=0;
		for(vector<int>::iterator it=t1[lol].v.begin(); it!=t1[lol].v.end(); it++)
		{
			if(odw[*it]==false)
			{
				siz[*it]--;
				if(siz[*it]<d)
				{
					odw[*it]=true;
					q.push(*it);
				}
			}
		}
	}
	//for(int i=1; i<=n; i++)printf("%d ", siz[i]);
	//printf("\n");
	for(int i=1; i<=m; i++)
	{
		a=drogi[i].first;
		b=drogi[i].second;
		if(siz[a]>=d&&siz[b]>=d)
		{
			t2[a].v.push_back(b);
			t2[b].v.push_back(a);
		}
	}
	/*for(int i=1; i<=n; i++)
	{
		printf("%d: ", i);
		for(vector<int>::iterator it=t2[i].v.begin(); it!=t2[i].v.end(); it++)
		{
			printf("%d ", *it);
		}
		printf("\n");
	}*/
	for(int i=1; i<=n; i++)
	{
		if(numer[i]==0&&siz[i]>=d)
		{
			q.push(i);
			numer[i]=i;
			pom=0;
			while(!q.empty())
			{
				lol=q.front();
				q.pop();
				pom++;
				for(vector<int>::iterator it=t2[lol].v.begin(); it!=t2[lol].v.end(); it++)
				{
					 if(numer[*it]==0)
					 {
					 	numer[*it]=i;
					 	q.push(*it);
					 }
				}
			}
			if(wyn<pom){wyn=pom; wynn=i;}
		}
	}
	if(wyn==0)
	{
		printf("NIE");
		return 0;
	}
	printf("%d\n", wyn);
	for(int i=1; i<=n; i++)
	{
		if(wynn==numer[i])printf("%d ", i);
	}
	return 0;
}