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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include <stdio.h>

#define FOR(ii, ll, uu)  for(int ii##lim = (uu), ii = (ll); ii < ii##lim; ++ii)
#define REP(ii, nn) FOR(ii, 0, nn)

typedef int SINT;
typedef unsigned UINT;

#define ABS(x) ((x)<0 ? -(x) : (x))

inline UINT giu()
{
	UINT n = 0;
	int ch = getchar_unlocked();
	while (ch < '0' || ch > '9')
	{
		ch = getchar_unlocked();
	}
	while (ch >= '0' && ch <= '9')
		n = (n<<3)+(n<<1) + ch-'0', ch = getchar_unlocked();
	return n;
}
#define GU (giu())

#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

struct city
{
	vector<int> nb_cit;
	int nb_num;
	bool excluded;
	int component;
	city() : nb_num(0), excluded(false), component(0) {}
	void add(int nb)
	{
		nb_cit.push_back(nb);
		++nb_num;
	}
	bool free()
	{
		return !excluded && component == 0;
	}
};

int main()
{
	int n = GU, m = GU, d = GU;
	
	vector<city> c(n+1);
	
	REP(i, m)
	{
		int ai = GU, bi = GU;
		c[ai].add(bi);
		c[bi].add(ai);
	}
	
	deque <int> exq;
	
	int n_excluded = 0;
	
	// initial out
	
	FOR(i, 1, n+1)
	{
		if (c[i].nb_num < d)
		{
			c[i].excluded = true;
			exq.push_back(i);
			++n_excluded;
		}
	}
	
	// chain reaction
	
	while (!exq.empty())
	{
		int v = exq.front(); exq.pop_front();
		REP(i, c[v].nb_cit.size())
		{
			int u = c[v].nb_cit[i];
			if (!c[u].excluded)
			{
				if (--c[u].nb_num < d)
				{
					c[u].excluded = true;
					exq.push_back(u);
					++n_excluded;
				}
			}
		}
	}
	
	if (n - n_excluded <= d)
	{
		puts("NIE");
		return 0;
	}
	
	vector<int> s; // solution
	
	FOR(i, 1, n+1)
	{
		if (c[i].free())
		{
			c[i].component = i;
			vector<int> s_cand(1, i);
			deque<int> q; q.push_back(i);			
			while (!q.empty())
			{
				int v = q.front(); q.pop_front();
				REP(j, c[v].nb_cit.size())
				{
					int u = c[v].nb_cit[j];
					if (c[u].free())
					{
						c[u].component = i;
						s_cand.push_back(u);
						q.push_back(u);
					}
				}
			}
			if (s_cand.size() > s.size())
			{
				s.swap(s_cand);
			}
		}
	}
	
	sort(s.begin(), s.end());
	
	printf("%d\n", (int)s.size());
	printf("%d", s[0]);
	FOR(i, 1, s.size())
		printf(" %d", s[i]);
	puts("");
	return 0;
}