#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int v, next;
} edge[100005 * 2];
int low[100005], dfn[100005], head[100005], S[100005], ans[100005];
int fuck[100005], color[100005];
bool vis[100005 * 2], in_stack[100005], yes[100005];
int n, m, edge_num, Index, K, S_top, st;
bool dye(int u, int pre, int sum, int c) {
  if (color[u] != 0) {
    if (sum > K + 1 && u == st) {
      fuck[sum] = u;
      fuck[0] = sum;
      return true;
    }
    return false;
  }
  color[u] = c;
  for (int k = head[u]; k != -1; k = edge[k].next) {
    int v = edge[k].v;
    if (v == pre || yes[v] == false) continue;
    if (dye(v, u, sum + 1, 3 - c)) {
      fuck[sum] = u;
      return true;
    }
  }
  return false;
}
bool judge(int u, int v) {
  int sum = 0, x;
  do {
    x = S[--S_top];
    in_stack[x] = false;
    ans[sum++] = x;
  } while (x != v);
  if (sum < K) return false;
  ans[sum++] = u;
  for (int i = 0; i < sum; i++) yes[ans[i]] = true, color[ans[i]] = 0;
  st = u;
  if (dye(u, u, 1, 1)) return true;
  for (int i = 0; i < sum; i++) yes[ans[i]] = false;
  return false;
}
bool Tarjan(int u) {
  dfn[u] = low[u] = Index++;
  S[S_top++] = u;
  in_stack[u] = true;
  for (int k = head[u]; k != -1; k = edge[k].next)
    if (!vis[k]) {
      vis[k] = vis[k ^ 1] = true;
      int v = edge[k].v;
      if (!dfn[v]) {
        if (Tarjan(v)) return true;
        low[u] = min(low[u], low[v]);
        if (low[v] >= dfn[u]) {
          if (judge(u, v)) return true;
        }
      } else if (in_stack[v])
        low[u] = min(low[u], dfn[v]);
    }
  return false;
}
void init() {
  edge_num = S_top = 0;
  Index = 1;
  memset(head, -1, sizeof(head));
  memset(dfn, 0, sizeof(dfn));
  memset(in_stack, false, sizeof(in_stack));
  memset(vis, false, sizeof(vis));
}
void add_edge(int u, int v) {
  edge[edge_num].v = v, edge[edge_num].next = head[u];
  head[u] = edge_num++;
}
int main() {
  int u, v;
  scanf("%d%d%d", &n, &m, &K);
  init();
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    add_edge(u, v), add_edge(v, u);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i])
      if (Tarjan(i)) break;
  printf("%d\n", fuck[0] - 1);
  for (int i = 1; i < fuck[0]; i++) printf("%d ", fuck[i]);
  puts("");
  return 0;
}
