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
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

vector <int> A[200002];
int tab[200002];
vector <int> skladowe;
vector <int> max_skladowe;

bool visited[200002];

void dfs( int v, int d )
{
    visited[v] = true;
    for( vector<int>::iterator it = A[v].begin(); it != A[v].end(); it ++ )
    {
        tab[*it] --;
        if( visited[*it] == false && tab[*it] < d  )
        {
            dfs( *it, d );
        }
    }
}
int K = 0;
int l = 0;
void dfs2( int v )
{
    l ++;
    skladowe.push_back(v);
    visited[v] = true;
    for( vector <int> :: iterator it = A[v].begin(); it != A[v].end(); it ++ )
    {
        if( visited[*it] == false  )
        {
            dfs2( *it );
        }
    }
}



int main()
{
    int n, m, d;
    scanf("%d %d %d", &n, &m, &d);
    for( int i = 0; i < m; i ++ )
    {
        int a, b;
        scanf("%d %d", &a, &b);
        A[a].push_back(b);
        A[b].push_back(a);
        tab[a] ++;
        tab[b] ++;
    }
    for( int i = 1; i <= n; i ++ )
    {
        if( tab[i] < d && visited[i] == false )
        {
            //visited[i] = false;
            dfs(i,d);
        }
    }
    for( int i = 1; i <= n; i ++ )
    {
        if( visited[i] == false )
        {
            l = 0;
            dfs2(i);
            if( l > K )
            {
                max_skladowe = skladowe;
                skladowe.clear();
                K = l;
            }
        }
    }
    if( K == 0 ) printf("NIE\n");
    else
    {
        printf("%d\n", K);
        sort(max_skladowe.begin(),max_skladowe.end());
        for( int i = 0; i < max_skladowe.size(); i ++ )
        {
            printf("%d ", max_skladowe[i]);
        }
    }

    return 0;
}