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
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(a,n) for(int a=0;a<n;++a)
#define REP1(a,n) for(int a=1;a<=n;++a)
#define P(a) cout<<#a<<": "<<(a)<<"\n"


const int MAXN=200*1000;

int n,m,d;
vector<int> v[MAXN];
int st[MAXN];

void remove(int i){
    queue<int> q;
    q.push(i);
    st[i]=-1;
    while(!q.empty()){
        int p=q.front();
        q.pop();
        for(auto a:v[p]){
            if(st[a]<0)continue;
            st[a]--;
            if(st[a]<d){
                q.push(a);
                st[a]=-1;
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>d;
    REP(a,m){
        int i,j;
        cin>>i>>j;
        --i; --j;
        v[i].push_back(j);
        v[j].push_back(i);
        ++st[i];
        ++st[j];
    }

    REP(a,n){
        if(st[a]<d && st[a]>0){
            remove(a);
        }
    }

    vector<int> ans;

    REP(a,n){
        if(st[a]>0){
            vector<int> ret;
            queue<int> q;
            q.push(a);
            st[a]=-1;
            while(!q.empty()){
                int p=q.front();
                q.pop();
                ret.push_back(p);
                for(auto b:v[p]){
                    if(st[b]<0)continue;
                    if(st[b]>0)q.push(b);
                    st[b]=-1;
                }
            }
            if(ret.size()>ans.size()){
                ans=ret;
            }
        }
    }

    if(ans.size()<=1){
        cout<<"NIE";
        return 0;
    }

    sort(ans.begin(),ans.end());
    cout<<ans.size()<<"\n";
    for(auto a:ans)
        cout<<a+1<<" ";
    return 0;
}