#include <bits/stdc++.h>
using namespace std;
vector<int> q[100002];
int ans[100002];
int flag, v[100002];
int k;
void dfs(int len, int x, int f) {
  int i;
  v[x] = len;
  ans[len] = x;
  for (i = 0; i < q[x].size(); i++) {
    int j = q[x][i];
    if (j == f) continue;
    if (v[j] != -1) {
      if (flag) break;
      if (len + 1 - v[j] >= k + 1) {
        printf("%d\n", len + 1 - v[j]);
        for (i = v[j]; i <= len; i++) {
          if (i != v[j]) printf(" ");
          printf("%d", ans[i]);
        }
        printf("\n");
        flag = 1;
        return;
      }
      continue;
    }
    dfs(len + 1, j, x);
  }
}
int main() {
  int n, m;
  while (scanf("%d%d%d", &n, &m, &k) != EOF) {
    while (m--) {
      int a, b;
      scanf("%d%d", &a, &b);
      q[a].push_back(b);
      q[b].push_back(a);
    }
    memset(v, -1, sizeof(v));
    dfs(0, 1, -1);
  }
  return 0;
}
