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
//Tadrion
#include <cstdio>
#include <vector>
#include <iostream>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
using namespace std;
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define CLEAR(x) (memset(x,0,sizeof(x)))
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define VAR(v, n) __typeof(n) v = (n)
#define FOR(x, b, e) for(int x = b; x <= (e); ++x)
#define FORD(x, b, e) for(int x = b; x >= (e); --x)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define FOREACH(i, c) for(VAR(i,(c).begin()); i != (c).end(); ++i)
#define DBG(v) cout<<#v<<" = "<<v<<endl;
#define IN(x,y) ((y).find(x)!=(y).end())
#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
typedef long long int LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
int n,m,d;
VI v[200010];
int color[200010];
int active[200010];

VI comps[200010];

int deg[200010],a,b;
deque<int> q;

void bfs(int s, int nr) {
    deque<int> q;
    color[s] = nr;
    q.PB(s);
    while(!q.empty()) {
        s = q.front();
        q.pop_front();
        //printf("%d jest w %d\n",s,nr);
        REP(i,SZ(v[s])) {
            if(active[v[s][i]] == 1 && color[v[s][i]] == 0) {
                color[v[s][i]] = nr;
                q.PB(v[s][i]);
            }
        }
    }
}

int main() {
  scanf("%d %d %d",&n,&m,&d);
  FOR(i,1,m) {
    scanf("%d %d",&a,&b);
    v[a].PB(b);
    v[b].PB(a);
  }
  FOR(i,1,n) {
    active[i] = 1;
    deg[i] = SZ(v[i]);
    if(deg[i] < d) q.PB(i);
  }
  while(!q.empty()) {

    int s = q.front();
    q.pop_front();
    //printf("za malo dla %d\n",s);
    active[s] = 0;
    REP(i,SZ(v[s])) {
        deg[v[s][i]]--;
        if(deg[v[s][i]]+1 == d && deg[v[s][i]] < d) q.PB(v[s][i]);
    }
  }
  int curColor = 1;
  FOR(i,1,n) {
    if(active[i] == 1 && color[i] == 0) {
        bfs(i,curColor);
        curColor++;
    }
  }
  FOR(i,1,n) {
    if(color[i] != 0) comps[color[i]].PB(i);
  }

  curColor--;

  int maxx = 0;
  int maxind = 0;
  FOR(i,1,curColor) {
    if(SZ(comps[i]) > maxx) {
        maxx = SZ(comps[i]);
        maxind = i;
    }
  }

    if(maxind == 0) {
        printf("NIE\n");
    }
    else {
        printf("%d\n",maxx);
        sort(comps[maxind].begin(),comps[maxind].end());
        REP(i,SZ(comps[maxind])) {
            printf("%d ",comps[maxind][i]);
        }
        printf("\n");
    }

  return 0;
}