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
#include<cstdio>
#include<algorithm>
#include<utility>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<iostream>

#define FORE(c, a, b) for(int c=a; c<= int(b); ++c)
#define FORD(c, a, b) for(int c=a; c>= int(b); --c)
#define FORIT(it, cont, cont_t) for(cont_t::iterator it = cont.begin(); it != cont.end(); ++it)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define ALL(a) a.begin(), a.end() 
#define PR(n) printf("%d ", (int) (n)) 
#define PRL(n) printf("%lld ", (ll) (n)) 
#define SC(n) scanf("%d ", &n) 

#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define itr iterator

#define dbg if(1)
#define prd dbg printf

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mi;
typedef pair<int, int> pi;
typedef vector<pi> vii;
typedef set<pi> spi;

const int NMAX = 200 * 1000 + 9;

int n, m, d, x, y;
int deg[NMAX], act[NMAX];
vi edges[NMAX], out, tmp;
spi kop;

void decc(int w) {
	kop.erase(mp(deg[w], w));
	deg[w]--;
	kop.insert(mp(deg[w], w));
}

void dfs(int w) {
	act[w] = 0;
	tmp.pb(w);
	FORIT(it, edges[w], vi)
		if(act[*it]) dfs(*it);
}

int main() {
	scanf("%d%d%d", &n, &m, &d);
	REP(i, m) {
		scanf("%d%d", &x, &y);
		x--; y--;
		edges[x].pb(y);
		edges[y].pb(x);
		deg[x]++; deg[y]++;
	}
	REP(i, n) {
		act[i] = 1;
		kop.insert(mp(deg[i], i));
	}
	
	while(!kop.empty() && kop.begin()->xx < d) {
		int v = kop.begin()->yy;
		kop.erase(kop.begin());
		act[v] = 0;
		FORIT(it, edges[v], vi)
			if(act[*it]) decc(*it);
	}	
	REP(i, n) if(act[i]) {
		tmp.clear();
		dfs(i);
		if(tmp.size() > out.size())
			out = tmp;
	}
	
	if(out.empty())
		printf("NIE");
	else {
		printf("%d\n", (int) out.size());
		sort(ALL(out));
		FORIT(it, out, vi)
			printf("%d ", *it + 1);
	}
	return 0;
}