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

const int maxN = 2e5 + 10;
vector<int>nbh[maxN];
vector<int>ans;
vector<int>ans_tmp;
bool B[maxN];
int deg[maxN];
int n, m, d;

void dfs(int v) {
    B[v] = true;
    ans_tmp.push_back(v);
    for(int a: nbh[v])
        if(!B[a])
            dfs(a);
}

void exterminate() {
    queue<int>q;
    for(int i = 1; i <= n; ++i) {
        deg[i] = nbh[i].size();
        if(deg[i] < d) {
            B[i] = true;
            q.push(i);
        }
    }
    int v;
    while(!q.empty()) {
        v = q.front();
        q.pop();
        for(int a: nbh[v]) {
            deg[a]--;
            if(!B[a] && deg[a] < d) {
                B[a] = true;
                q.push(a);
            }
        }
    }
}

int main() {
    scanf("%d%d%d", &n, &m, &d);
    for(int a, b, i = 0; i < m; ++i) {
        scanf("%d%d", &a, &b);
        nbh[a].push_back(b);
        nbh[b].push_back(a);
    }
    exterminate();
    for(int i = 1; i <= n; ++i) {
        if(!B[i]) {
            dfs(i);
            if(ans.size() < ans_tmp.size())
                ans = ans_tmp;
            ans_tmp.clear();
        }
    }
    if(!ans.size()) {
        printf("NIE\n");
        return 0;
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", (int) ans.size());
    for(int a: ans) printf("%d ", a);
    printf("\n");
    return 0;
}