#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100010];
int used[100010];
int parent[100010];
int tim[100010];
int n, t = 0, k;
bool done = false;
void printpath(int first, int last) {
  if (first == last) {
    cout << first << " ";
    return;
  }
  printpath(first, parent[last]);
  cout << last << " ";
  return;
}
void Dfs(int i) {
  t++;
  used[i] = true;
  tim[i] = t;
  for (int h = 0; h < graph[i].size(); h++) {
    int j = graph[i][h];
    if (!used[j]) {
      parent[j] = i;
      Dfs(j);
      if (done) return;
    } else if (used[j] && parent[j] != i && tim[i] - tim[j] >= k) {
      cout << tim[i] - tim[j] + 1 << endl;
      printpath(j, i);
      done = true;
      return;
    }
  }
}
int main() {
  int m;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  for (int i = 0; i < n && !done; i++) {
    if (!used[i]) {
      Dfs(i);
    }
  }
  return 0;
}
