#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
int n, m, k, flag;
int vis[MAX_N], deep[MAX_N];
vector<int> G[MAX_N], path;
void dfs(int pos, int step) {
  if (vis[pos]) return;
  vis[pos] = 1;
  deep[pos] = step;
  path.push_back(pos);
  int size = G[pos].size();
  for (int i = 0; i < size && !flag; i++) {
    int v = G[pos][i];
    if (vis[v] && step - deep[v] >= k) {
      printf("%d\n", step - deep[v] + 1);
      for (int j = deep[v]; j <= step; j++) {
        printf("%d%c", path[j], j == step ? '\n' : ' ');
      }
      flag = 1;
    } else {
      dfs(v, step + 1);
    }
  }
  path.pop_back();
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int u, v;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  return 0;
}
