#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, k;
vector<int> vec[N];
int visited[N];
int papanode[N];
bool q;
void print(int u, int v) {
  if (q) return;
  cout << u << ' ';
  if (u != v)
    print(papanode[u], v);
  else
    q = 1;
}
void dfs(int v, int siz) {
  if (q) return;
  visited[v] = siz;
  for (int i = 0; i < vec[v].size(); i++) {
    int u = vec[v][i];
    if (!visited[u]) {
      papanode[u] = v;
      dfs(u, siz + 1);
    } else {
      if (q) return;
      if (siz - visited[u] >= k && visited[u] != siz - 1) {
        cout << siz - visited[u] + 1 << endl;
        print(v, u);
        q = 1;
      }
    }
  }
}
int main() {
  cin >> n >> m >> k;
  int u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  dfs(1, 1);
  return 0;
}
