#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#define endl "\n"
typedef long long ll;
const int MAKS = 200 * 1000;
using namespace std;
vector<int> neighbours[MAKS];
bool visited[MAKS];
int non[MAKS];
int n, m, d;
void decrease(int k){
non[k] = -1;
for (int i = 0; i < neighbours[k].size(); i++){
int pom = neighbours[k][i];
if (non[pom] != -1){
non[pom]--;
if (non[pom] < d)
decrease(pom);
}
}
}
void read(){
int a, b;
cin >> n >> m >> d;
for(int i = 0; i < m; i++){
cin >> a >> b;
a--;
b--;
neighbours[a].push_back(b);
neighbours[b].push_back(a);
non[a]++;
non[b]++;
}
for (int i = 0; i < n; i++){
if (non[i] > 0 && non[i] < d)
decrease(i);
}
}
void solve(){
queue <int> bfs;
vector<int> bestanswer;
for (int i = 0; i < n; i++){
if (!visited[i] && non[i] >= d){
vector<int>currentanswer;
bfs.push(i);
while (!bfs.empty()){
int idx = bfs.front();
bfs.pop();
if (!visited[idx]){
visited[idx] = 1;
currentanswer.push_back(idx);
int sizeoofneighbour = neighbours[idx].size();
for (int j = 0; j < sizeoofneighbour; j++){
int a = neighbours[idx][j];
if (non[a] >= d && !visited[a])
bfs.push(a);
}
}
if (currentanswer.size() > bestanswer.size())
bestanswer = currentanswer;
}
}
}
sort(bestanswer.begin(), bestanswer.end());
int pom2 = bestanswer.size();
if (pom2 < 2){
cout << "NIE" << endl;
return;
}
cout << pom2 << endl;
for (int i = 0; i < pom2 - 1; i++){
cout << bestanswer[i] + 1 << " ";
}
cout << bestanswer[pom2 -1] + 1<< endl;
}
int main() {
ios_base::sync_with_stdio(0);
read();
solve();
return 0;
}