#include <bits/stdc++.h>
using namespace std;
int n, m, k, d[200010], vis[200010], t;
vector<int> g[200010], ans;
bool dfs(int root) {
  ans.push_back(root);
  d[root] = ++t;
  for (int c : g[root]) {
    if (d[c] > 0 && d[root] - d[c] + 1 > k) {
      int tmp = d[root] - d[c] + 1;
      cout << tmp << '\n';
      while (tmp--) {
        cout << ans.back() + 1 << " ";
        ans.pop_back();
      }
      return 1;
    }
    if (d[c] == 0) {
      if (dfs(c)) return 1;
    }
  }
  return 0;
}
void code() {
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (d[i] == 0) {
      ans.clear();
      if (dfs(i)) return;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    code();
  }
}
