#include <bits/stdc++.h>
using namespace std;
vector<int> l[100007];
int parent[100007];
int color[100007];
int k;
int p;
int dfs(int u, int c) {
  int sz = l[u].size();
  {
    for (int i = 0; i < sz; i++) {
      if (color[u] - color[l[u][i]] >= k && color[l[u][i]] != 0) {
        parent[l[u][i]] = u;
        return u;
      } else if (color[l[u][i]] == 0) {
        color[l[u][i]] = c + 2;
        parent[l[u][i]] = u;
        return dfs(l[u][i], c + 1);
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m >> k;
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    l[a].push_back(b);
    l[b].push_back(a);
  }
  color[1] = 1;
  int u = dfs(1, 0);
  int v = parent[u];
  int cycle = 1;
  while (v != u) {
    v = parent[v];
    cycle++;
  }
  cout << cycle << endl;
  cout << u << " ";
  v = parent[u];
  while (v != u) {
    cout << v << " ";
    v = parent[v];
  }
}
