#include <bits/stdc++.h>
using namespace std;
vector<int> v[100010];
vector<int> ans;
int k;
int n;
int m;
int st;
int vis[100010];
bool dfs(int i, int dep) {
  ans.push_back(i);
  vis[i] = dep;
  for (int j = 0; j < v[i].size(); ++j) {
    if (vis[v[i][j]] == -1) {
      if (dfs(v[i][j], dep + 1)) return true;
    } else if (vis[v[i][j]] + k <= dep) {
      st = v[i][j];
      return true;
    }
  }
  return false;
}
int main() {
  while (scanf("%d%d%d", &n, &m, &k) == 3) {
    ans.clear();
    memset(vis, 0xff, sizeof(vis));
    for (int i = 0; i <= n; ++i) v[i].clear();
    for (int i = 0; i < m; ++i) {
      int a, b;
      scanf("%d%d", &a, &b);
      v[a].push_back(b);
      v[b].push_back(a);
    }
    st = -1;
    if (false == dfs(1, 0)) puts("error");
    int i = 0;
    while (i < ans.size()) {
      if (ans[i] == st) break;
      i++;
    }
    printf("%d\n", ans.size() - i);
    for (; i < ans.size(); ++i) {
      printf("%d ", ans[i]);
    }
    puts("");
  }
  return 0;
}
