#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
int n, m, k, x, y, d[MAX], p[MAX], pointer = 1, par, len;
bool v[MAX], cycle[MAX];
vector<int> a[MAX], answer;
void DFS(int start) {
  v[start] = true;
  int current;
  for (int i = 0; i < a[start].size(); i++) {
    current = a[start][i];
    if (!v[current]) {
      d[current] = (d[start] + 1);
      if (d[current] > d[pointer]) {
        pointer = current;
      }
      p[current] = start;
      DFS(current);
    }
  }
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  DFS(1);
  answer.push_back(pointer);
  par = p[pointer];
  while (par != 1) {
    answer.push_back(par);
    par = p[par];
  }
  answer.push_back(1);
  for (int i = 0; i < a[pointer].size(); i++) {
    cycle[a[pointer][i]] = true;
  }
  for (int i = answer.size() - 1; i >= 0; i--) {
    if (cycle[answer[i]]) {
      len = i;
      break;
    }
  }
  cout << len + 1 << "\n";
  for (int i = 0; i <= len; i++) {
    cout << answer[i] << " ";
  }
  cout << "\n";
  return 0;
}
