#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int d[N], n, m, trace[N], k, u, v;
bool Free[N];
vector<int> ans, a[N];
void dfs(int u) {
  Free[u] = false;
  for (int i = 0; i < a[u].size(); ++i) {
    int v = a[u][i];
    if (Free[v]) {
      d[v] = d[u] + 1;
      trace[v] = u;
      dfs(v);
    } else {
      if (d[u] - d[v] >= k) {
        int curr = u;
        while (trace[curr] != v) {
          ans.push_back(curr);
          curr = trace[curr];
        }
        ans.push_back(curr);
        ans.push_back(v);
        cout << ans.size() << "\n";
        reverse(ans.begin(), ans.end());
        for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
        exit(0);
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    a[u].push_back(v);
    a[v].push_back(u);
  }
  d[1] = 1;
  memset(Free, true, sizeof(Free));
  for (int i = 1; i <= n; ++i)
    if (Free[i]) dfs(i);
}
