#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T &t, T f) {
  if (t > f) t = f;
}
template <class T>
void chmax(T &t, T f) {
  if (t < f) t = f;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
T cube(T x) {
  return x * x * x;
}
string out(long long x) {
  stringstream ss;
  ss << x;
  string res;
  ss >> res;
  return res;
}
long long out(string s) {
  stringstream ss;
  ss << s;
  long long res;
  ss >> res;
  return res;
}
template <typename T>
void print(const vector<vector<T> > &v) {
  for (int i = 0; i < (int)(v.size()); i++) {
    cout << "i = " << i << endl;
    for (int j = 0; j < (int)(v[i].size()); j++) {
      cout << v[i][j] << ' ';
    }
    cout << endl;
    cout << endl;
  }
}
template <typename T>
void print(const vector<T> &v) {
  for (int i = 0; i < (int)(v.size()); i++) {
    cout << v[i] << ' ';
  }
  cout << endl;
}
void func() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  vector<pair<int, int> > tmp;
  for (int i = 0; i < (int)(n - 1); i++) {
    tmp.push_back(make_pair(a[i], a[i + 1]));
    tmp.push_back(make_pair(a[i], a[(i + 2) % n]));
  }
  for (int i = 0; i < (int)(tmp.size()); i++) {
    printf("%d %d\n", tmp[i].first, tmp[i].second);
  }
}
const int MAXN = 100000 + 7;
int cnt[MAXN];
int mas[MAXN][4];
vector<vector<int> > g;
int n, m, k;
vector<char> cl;
vector<int> p;
int cycle_st, cycle_end;
vector<int> depth;
bool dfs(int v, int prev = -1) {
  cl[v] = 1;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (cl[to] == 0) {
      p[to] = v;
      depth[to] = depth[v] + 1;
      if (dfs(to, v)) return true;
    } else if (cl[to] == 1 && depth[v] - depth[to] >= k && prev != to) {
      cycle_end = v;
      cycle_st = to;
      return true;
    }
  }
  cl[v] = 2;
  return false;
}
int main() {
  cin >> n >> m >> k;
  g.resize(n);
  depth.resize(n);
  for (int i = 0; i < (int)(m); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  p.assign(n, -1);
  cl.assign(n, 0);
  cycle_st = -1;
  for (int i = 0; i < n; ++i)
    if (dfs(i)) break;
  if (cycle_st == -1) {
    exit(1);
  }
  vector<int> cycle;
  cycle.push_back(cycle_st);
  for (int v = cycle_end; v != cycle_st; v = p[v]) cycle.push_back(v);
  cycle.push_back(cycle_st);
  cycle.pop_back();
  printf("%d\n", cycle.size());
  for (int i = 0; i < cycle.size(); ++i) printf("%d ", cycle[i] + 1);
  return 0;
}
