#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1061109567;
const int maxn = 1e5 + 5;
int head[maxn * 2], d[maxn], Dfs[maxn], ans[maxn], cnt = 0;
struct node {
  int to, nextt;
} e[maxn * 2];
int num = 0;
void add(int u, int v) {
  e[num].to = v;
  e[num].nextt = head[u];
  head[u] = num++;
}
int k, st, ed;
int dfs(int u, int de, int fa) {
  Dfs[u] = de;
  ans[de] = u;
  for (int i = head[u]; ~i; i = e[i].nextt) {
    int v = e[i].to;
    if (Dfs[v]) {
      if (de - Dfs[v] < k) {
        continue;
      }
      ed = de;
      st = Dfs[v];
      return 1;
    }
    if (dfs(v, de + 1, u)) return 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m >> k;
  memset(head, -1, sizeof(head));
  int x, y;
  while (m--) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(1, 0, -1);
  cout << ed - st + 1 << endl;
  for (int i = st; i <= ed; i++) {
    cout << ans[i] << " ";
  }
}
