#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int n, m, k;
vector<int> adj[100010], vec;
int vst[100010], dep[100010], pre[100010];
void dfs(int u, int father = 0) {
  dep[u] = dep[father] + 1;
  pre[u] = father;
  vst[u] = 1;
  for (auto v : adj[u]) {
    if (!vst[v])
      dfs(v, u);
    else if (vst[v] == 2 && dep[v] - dep[u] + 1 > k) {
      printf("%d\n", dep[v] - dep[u] + 1);
      for (int i = v; i != u; i = pre[i]) vec.push_back(i);
      vec.push_back(u);
      for (int i = vec.size(); i--;) printf("%d ", vec[i]);
      puts("");
      exit(0);
    }
  }
  vst[u] = 2;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v), adj[v].push_back(u);
  }
  dfs(1);
  return 0;
}
