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
// mistrzostwa
#include <iostream>
#include <vector>
#define FORD(a, b, e) for(int a = b; a >= e; a--)
#define VAR(a, b) __typeof(b) a = b
#define FOREACH(a, b) for(VAR(a, (b).begin()); a != (b).end(); a++)
#define SIZE(a) (int)a.size()
#define REP(a, b) for(int a = 0; a < b; a++)
#define PB push_back

using namespace std;
typedef vector<int> VI;

static int d = 0;

template <class V, class E> struct Graph
{
    struct Ed: E
    {
        int v;
        Ed(int w, E e): v(w), E(e) {}
    };

    struct Ve: V, vector<Ed> {};

    vector<Ve> g;

    Graph(int n = 0): g(n) {}

    void EdgeU(int a, int b, E e = E())
    {
        Ed eg(b, e);
        eg.rev = SIZE(g[b]) + (a==b);
        g[a].PB(eg);
        eg.rev = SIZE(g[eg.v = a]) - 1;
        g[b].PB(eg);
    }


    int Search()
    {
        int sizz = 0, s;

        REP(x, SIZE(g))
        {
            s = 0;
            if(!g[x].deleted) {
                FOREACH(it, g[x]) if(!g[it->v].deleted) s++;

                if( s < d)
                {
                    g[x].deleted = true;
                    x = 0, sizz = 0;
                    continue;
                }
                else
                {
                    sizz++;
                }
            }
        }

        return sizz;
    }

};

struct V{
    int t;
    bool deleted = false;
};
struct E
{
    int rev;
};

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m, a, b;
    cin >> n >> m >> d;
    Graph<V, E> g(n);

    REP(x, m)
    {
        cin >> a >> b;
        g.EdgeU(a-1, b-1);
    }
    int wyn = g.Search();

    if(wyn == 0) cout << "NIE" << endl;
    else{
        cout << g.Search() << endl;

        REP(x, n)
        {
            if(!g.g[x].deleted)
            {
                cout << x+1 << " ";
                FOREACH(it, g.g[x]) if(!g.g[it->v].deleted) cout << it->v+1 << " ";

                break;
            }
        }
    }
}