#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int MAXN = 200*1000 + 9;
vector<int> g[MAXN];
int kolor[MAXN];
int KOLOR = 1;
int dfs(int x){
if(kolor[x]) return 0;
kolor[x] = KOLOR;
int s = 1;
for(int i = 0; i < g[x].size(); ++i)
s += dfs(g[x][i]);
return s;
}
int main(){
ios_base::sync_with_stdio(0);
int n, m, d;
cin >> n >> m >> d;
for(int i = 0; i < m; ++i){
int a, b;
cin >> a >> b;
a--;
b--;
g[a].push_back(b);
g[b].push_back(a);
}
queue<int> q;
vector<int> st(n);
for(int x = 0; x < n; ++x){
st[x] = g[x].size();
if(st[x] < d) q.push(x);
}
while(!q.empty()){
int x = q.front(); q.pop();
for(int i = 0; i < g[x].size(); ++i){
int y = g[x][i];
if(st[y] == d) q.push(y);
st[y]--;
}
}
for(int x = 0; x < n; ++x){
if(st[x] < d) g[x].clear();
for(int i = 0; i < g[x].size();){
int y = g[x][i];
if(st[y] < d){
swap(g[x][i], g[x].back());
g[x].pop_back();
}
else i++;
}
}
int najile = 0, najkolor = 0;
for(int x = 0; x < n; ++x){
KOLOR = x+5;
int ile = dfs(x);
if(ile > najile){
najile = ile;
najkolor = KOLOR;
}
}
if(najile > d){
cout << najile << "\n";
for(int x = 0; x < n; ++x)
if(kolor[x] == najkolor) cout << x+1 << " ";
}
else cout << "NIE\n";
}