#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005], v;
;
bool vis[100005];
int par[100005] = {}, k, c[100005] = {}, st[100005] = {}, l = 0, x;
int dfs(int s) {
  vis[s] = true;
  st[s] = 1;
  if (l != 0) return x;
  for (int i = 0; i < adj[s].size(); i++) {
    if (vis[adj[s][i]] == false) {
      c[adj[s][i]] = c[s] + 1;
      par[adj[s][i]] = s;
      dfs(adj[s][i]);
    } else if (st[adj[s][i]] == 1 && c[s] - c[adj[s][i]] > 1) {
      if (c[s] - c[adj[s][i]] + 1 >= k + 1) {
        l = c[s] - c[adj[s][i]] + 1;
        x = s;
        return x;
      }
    }
  }
  if (l != 0) return x;
  cout << "aya";
  st[s] = -1;
  return 0;
}
int main() {
  int m, n, i, a, b, d;
  cin >> n >> m >> k;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    if (vis[i] == false) d = dfs(i);
    if (d != 0) {
      cout << l << endl;
      while (--l) {
        cout << d << " ";
        d = par[d];
      }
      cout << d;
      break;
    }
  }
}
