#include <bits/stdc++.h>
using namespace std;
vector<int> graph[200005];
bool to[200005];
int rec[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, a, b, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  to[1] = true;
  vector<int> vertex;
  vertex.push_back(1);
  int ini, fin;
  bool flag = false;
  rec[1] = 0;
  for (int i = 0; i < n; i++) {
    int v = vertex[i];
    for (int j = 0; j < graph[v].size(); j++) {
      int u = graph[v][j];
      if (to[u]) {
        if (i - rec[u] + 2 > k) {
          ini = rec[u];
          fin = i + 1;
          flag = true;
          break;
        }
      }
    }
    if (flag) break;
    for (int j = 0; j < graph[v].size(); j++) {
      int u = graph[v][j];
      if (!to[u]) {
        to[u] = true;
        vertex.push_back(u);
        rec[v] = i + 1;
        break;
      }
    }
  }
  cout << vertex.size() - ini + 1 << endl;
  for (int i = ini - 1; i < fin; i++) cout << vertex[i] << " ";
  return 0;
}
