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
#include<cstdio>
#include<vector>
#include<queue>
#define MP make_pair
#define fi first
#define se second
using namespace std;
const int N = 2 * 1e5 + 1;
priority_queue<pair<int, int> >q;
int n, m, d, a, b, i, l, mx, start, st[N];
vector<int>v[N];
bool usuniete[N], w[N];

void dfs(int x)
{
  w[x] = 1;
  l++;
  for(int i = 0; i < v[x].size(); i++)
  {
    if (w[v[x][i]] == 0 && usuniete[v[x][i]] == 0)
    {
      dfs(v[x][i]);
    }
  }
}

int main()
{
  scanf("%d%d%d", &n, &m, &d);
  
  while(m--)
  {
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    st[a]++;
    v[b].push_back(a);
    st[b]++;
  }
  
  for(i = 1; i <= n; i++)
  {
    q.push(MP(v[i].size() * (-1), i));
  }
  
  while(!q.empty())
  {
    a = q.top().se;
    b = q.top().fi * (-1);
    q.pop();
    if (st[a] >= d)
    {
      break;
    }
    if (usuniete[a] == 0 && st[a] == b)
    {
      usuniete[a] = 1;
      for(i = 0; i < v[a].size(); i++)
      {
	b = v[a][i];
	if (usuniete[b] == 0)
	{
	  st[a]--;
	  st[b]--;
	  q.push(MP(st[b] * (-1), b));
	}
      }
    }
  }
  
  for(i = 1; i <= n; i++)
  {
    if (usuniete[i] == 0 && w[i] == 0)
    {
      l = 0;
      dfs(i);
      if (l > mx)
      {
	mx = l;
	start = i;
      }
    }    
  }
  for(i = 1; i <= n; i++)
  {
    w[i] = 0;
  }
  
  if (l == 0)
  {
    printf("NIE\n");
    return 0;
  }
  
  dfs(start);
  
  printf("%d\n", mx);
  for(i = 1; i <= n; i++)
  {
    if (w[i] == 1)
    {
      printf("%d ", i);
    }
  }
  printf("\n");
  
return 0;
}