#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> G;
vector<bool> vis;
vector<int> h, p;
int n, m, k;
void DFS(int u) {
  vis[u] = true;
  for (auto &v : G[u]) {
    if (!vis[v]) {
      vis[v] = true;
      p[v] = u;
      h[v] = h[u] + 1;
      DFS(v);
    } else if (h[u] - h[v] + 1 > k) {
      int x = u;
      cout << h[u] - h[v] + 1 << endl;
      for (int i = 0; i < h[u] - h[v] + 1; i++) {
        cout << x + 1 << " ";
        x = p[x];
      }
      exit(0);
    }
  }
}
int main() {
  int u, v;
  cin >> n >> m >> k;
  G.resize(n);
  vis.resize(n);
  fill_n(vis.begin(), n, false);
  h.resize(n);
  p.resize(n);
  while (m--) {
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  DFS(0);
  return 0;
}
