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
#include<cstdio>
#include<algorithm>
#define N 200010
int n,m,D,x,y,i,g[N],v[N<<1],nxt[N<<1],ed,d[N],h,t,q[N],del[N],ans,fin[N];
inline void read(int&a){char c;while(!(((c=getchar())>='0')&&(c<='9')));a=c-'0';while(((c=getchar())>='0')&&(c<='9'))(a*=10)+=c-'0';}
inline void add(int x,int y){d[x]++;v[++ed]=y;nxt[ed]=g[x];g[x]=ed;}
void dfs(int x){
  if(del[x])return;
  del[q[++t]=x]=1;
  for(int i=g[x];i;i=nxt[i])dfs(v[i]);
}
int main(){
  read(n),read(m),read(D);
  while(m--)read(x),read(y),add(x,y),add(y,x);
  for(i=h=1;i<=n;i++)if(d[i]<D)del[q[++t]=i]=1;
  while(h<=t)for(i=g[x=q[h++]];i;i=nxt[i]){
    d[v[i]]--;
    if(d[v[i]]<D&&!del[v[i]])del[q[++t]=v[i]]=1;
  }
  for(i=1;i<=n;i++)if(!del[i]){
    t=0,dfs(i);
    if(t>ans)for(ans=t,x=1;x<=t;x++)fin[x]=q[x];
  }
  if(!ans)return puts("NIE"),0;
  if(ans>1)std::sort(fin+1,fin+ans+1);
  for(printf("%d\n",ans),i=1;i<=ans;i++)printf("%d ",fin[i]);
  return 0;
}