#include <bits/stdc++.h>
using namespace std;
int n, m, k, ans;
vector<int> graph[100001];
int vis[100001], d[100001];
bool flag = false;
vector<int> res;
void dfs(int v, int par) {
  vis[v] = 1;
  for (int i : graph[v]) {
    if (i == par) continue;
    if (vis[i] == 1) {
      if (d[v] - d[i] + 1 > k) {
        flag = true;
        ans = d[v] - d[i];
        res.push_back(v);
        return;
      }
      continue;
    }
    d[i] = 1 + d[v];
    dfs(i, v);
    if (flag) {
      if (ans) {
        res.push_back(v);
        ans -= 1;
      }
      return;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(vis, 0, 100001);
  memset(d, 0, 100001);
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  dfs(1, 0);
  cout << res.size() << '\n';
  for (int i = 0; i < res.size(); i++) cout << res[i] << ' ';
  return 0;
}
