#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline string get() {
  char ch[1000010];
  scanf("%s", ch);
  return ch;
}
const int MAX_LG = 40;
const long long maxn = 1e5 + 100;
const long long base = 29;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 100;
vector<long long> g[maxn];
bool mark[maxn];
bool N[maxn];
vector<long long> path;
inline void dfs(long long v) {
  mark[v] = true;
  path.push_back(v);
  for (auto u : g[v]) {
    if (mark[u]) continue;
    dfs(u);
    break;
  }
}
int32_t main() {
  long long n = in(), m = in(), k = in();
  for (long long i = 0; i < m; i++) {
    long long v = in() - 1, u = in() - 1;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs(0);
  long long en = path.back();
  for (auto u : g[en]) N[u] = true;
  long long cur = 0;
  for (auto v : path) {
    if (N[v]) {
      cout << (long long)path.size() - cur << "\n";
      break;
    }
    cur++;
  }
  for (long long j = cur; j < path.size(); j++) cout << path[j] + 1 << " ";
  cout << "\n";
}
