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
#include <bits/stdc++.h>
using namespace std;

#define fru(j,n) for(int j=0; j<(n); ++j)
#define tr(it,v) for(auto it=(v).begin(); it!=(v).end(); ++it)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ALL(G) (G).begin(),(G).end()

typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int inft = 1000000009;
const int MAXN = 1000006;

vi V[MAXN];
int outdeg[MAXN];
bool nonvalid[MAXN];
vi ANS,T;

void dfs(int a){
	T.pb(a);
	nonvalid[a]=1;
	tr(it,V[a])if(!nonvalid[*it])dfs(*it);
}
void solve() {
	int n,m,d;
	scanf("%d%d%d",&n,&m,&d);
	fru(i,m){
		int a,b;
		scanf("%d%d",&a,&b);a--;b--;
		outdeg[a]++;
		outdeg[b]++;
		V[b].pb(a);
		V[a].pb(b);
	}
	int total=n;
	queue<int> Q;
	fru(i,n)if(outdeg[i]<d)Q.push(i);
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		nonvalid[u]=1;total--;
		tr(it,V[u]){
			outdeg[*it]--;
			if(outdeg[*it]==d-1)Q.push(*it);
		}
	}
	if(total==0){puts("NIE");return;}
	fru(i,n)if(!nonvalid[i]){
		dfs(i);
		if(ANS.size()<T.size())swap(T,ANS);
		T.clear();
	}
	sort(ALL(ANS));
	printf("%d\n",ANS.size());
	tr(it,ANS)printf("%d ",*it+1);puts("");
}

int main() {
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	int t=1;
//	scanf("%d",&t);
	fru(i,t) solve();
	return 0;
}