#include <bits/stdc++.h>
using namespace std;
vector<int> graph[1000000];
int recursionS[1000000];
int p[1000000], found = 0, st, n, m, k, l;
void dfs(int x, int pos, int par) {
  int u;
  recursionS[x] = pos;
  for (int i = 0; i < graph[x].size() && found == 0; i++) {
    u = graph[x][i];
    if (recursionS[u] && u != par) {
      if (recursionS[x] - recursionS[u] >= k)
        found = u, st = x, l = recursionS[x] - recursionS[u];
      else
        continue;
    } else if (!recursionS[u])
      p[u] = x, dfs(u, pos + 1, x);
  }
  recursionS[x] = 0;
  return;
}
int main() {
  cin >> n >> m >> k;
  int u, v;
  for (int i = 0; i < m; i++)
    cin >> u >> v, graph[u].push_back(v), graph[v].push_back(u);
  dfs(1, 1, -1);
  cout << l + 1 << endl;
  cout << st << " ";
  while (st != found) st = p[st], cout << st << " ";
  return 0;
}
