#include <bits/stdc++.h>
using namespace std;
int N, M, K;
vector<int> adj[100005];
int status[100005];
int dfs_number[100005];
vector<int> ans;
int done = 0;
void dfs(int now, stack<int> *s) {
  if (done) return;
  (*s).push(now);
  status[now] = 1;
  int ss = adj[now].size();
  for (int i = 0; i < ss && !done; i++) {
    int v = adj[now][i];
    if (status[v] == 0) {
      dfs_number[v] = dfs_number[now] + 1;
      dfs(v, s);
    } else if (status[v] == 1) {
      if (dfs_number[now] - dfs_number[v] >= K && !done) {
        while ((*s).top() != v) {
          ans.push_back((*s).top());
          (*s).pop();
        }
        ans.push_back(v);
        done = 1;
        return;
      }
    }
  }
  if (done) return;
  (*s).pop();
  status[now] = 2;
}
int main() {
  int a, b;
  scanf("%d %d %d", &N, &M, &K);
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  stack<int> s;
  dfs_number[1] = 1;
  dfs(1, &s);
  printf("%d\n", ans.size());
  printf("%d", ans[0]);
  for (int i = 1; i < ans.size(); i++) printf(" %d", ans[i]);
  printf("\n");
  return 0;
}
