#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5 + 7;
int n, m, k;
vector<int> g[NMAX];
pair<int, int> res = {-1, -1};
int len;
int vis[NMAX], tin[NMAX], tid[NMAX], par[NMAX];
int ideeees = 0;
void Dfs(int cur) {
  if (res.second >= 0) return;
  vis[cur] = 1;
  tin[cur] = ++ideeees;
  tid[ideeees] = cur;
  for (int i : g[cur]) {
    if (!vis[i]) {
      Dfs(i);
      par[i] = cur;
    } else {
      if (tin[cur] - tin[i] + 1 > k) {
        res = {i, cur};
        len = tin[cur] - tin[i] + 1;
        return;
      }
    }
  }
}
int main() {
  cin >> n >> m >> k;
  while (m--) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  Dfs(1);
  cout << len << endl;
  int x = res.second;
  int y = res.first;
  while (x != y) {
    cout << x << " ";
    x = par[x];
  }
  cout << y;
  return 0;
}
