#include <bits/stdc++.h>
using namespace std;
int n, m, k;
struct Edge {
  int from, to;
  int next;
} edge[2 * 100100];
int head[100100];
int w, a, b;
void add_edge(int from, int to) {
  w++;
  edge[w].from = from;
  edge[w].to = to;
  edge[w].next = head[from];
  head[from] = w;
}
stack<int> st;
int step[100100], limit, num;
bool quit;
void dfs(int now, int sum) {
  step[now] = sum;
  st.push(now);
  int i, to;
  for (i = head[now]; i != -1; i = edge[i].next) {
    to = edge[i].to;
    if (!step[to]) {
      dfs(to, sum + 1);
      if (!quit) {
        int t = st.top();
        st.pop();
        step[t] = 0;
      } else
        return;
    } else if (step[now] - step[to] + 1 >= k + 1) {
      quit = true;
      limit = to;
      num = step[now] - step[to] + 1;
      return;
    }
  }
}
int main() {
  cin >> n >> m >> k;
  w = 0;
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &a, &b);
    add_edge(a, b);
    add_edge(b, a);
  }
  memset(step, 0, sizeof(step));
  quit = false;
  dfs(1, 1);
  bool first = true;
  printf("%d\n", num);
  while (!st.empty()) {
    if (first)
      first = false;
    else
      printf(" ");
    int t = st.top();
    printf("%d", t);
    st.pop();
    if (t == limit) break;
  }
  printf("\n");
}
