#include <bits/stdc++.h>
using namespace std;
bitset<100999> viz;
int lvl[100999];
int tata[100999];
vector<int> gr[100999];
inline void dfs(int nod, int lvls, int k) {
  viz[nod] = 1;
  lvl[nod] = lvls;
  for (auto x : gr[nod])
    if (!viz[x]) {
      tata[x] = nod;
      dfs(x, lvls + 1, k);
    } else {
      if (lvl[x] - lvl[nod] + 1 > k) {
        cout << lvl[x] - lvl[nod] + 1 << '\n';
        int xx = x;
        while (xx != tata[nod]) {
          cout << xx << ' ';
          xx = tata[xx];
        }
        exit(0);
      }
    }
}
int main() {
  ios ::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  while (m--) {
    int x, y;
    cin >> x >> y;
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  dfs(1, 0, k);
  return 0;
}
