#include <bits/stdc++.h>
using namespace std;
vector<int> G[100010];
int n, m, k;
bool dfs(int v, vector<int>& res, vector<int>& visited) {
  for (auto u : G[v]) {
    if (visited[u] and res.size() - visited[u] + 1 > k) {
      cout << res.size() - visited[u] + 1 << endl;
      for (int i = visited[u] - 1; i < res.size(); ++i)
        cout << res[i] + 1 << ' ';
      cout << endl;
      return true;
    } else if (!visited[u]) {
      res.push_back(u);
      visited[u] = res.size();
      if (dfs(u, res, visited)) return true;
      res.pop_back();
      visited[u] = 0;
    }
  }
  return false;
}
int main() {
  cin >> n >> m >> k;
  while (m--) {
    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) {
    vector<int> res, visited(n);
    res.push_back(i);
    visited[i] = 1;
    if (dfs(i, res, visited)) break;
  }
}
