#include <bits/stdc++.h>
using namespace std;
bool vis[100001];
int pi[100001];
int level[100001];
list<int> adj[100001];
void dfs(int s) {
  vis[s] = 1;
  bool flag = 1;
  for (list<int>::iterator it = adj[s].begin(); it != adj[s].end(); ++it)
    if (!vis[*it]) {
      level[*it] = level[s] + 1;
      pi[*it] = s;
      dfs(*it);
      flag = 0;
    }
  if (flag) {
    int least = s;
    stack<int> stk;
    for (list<int>::iterator it = adj[s].begin(); it != adj[s].end(); ++it)
      if (level[least] > level[(*it)]) least = *it;
    while (s != least) {
      stk.push(s);
      s = pi[s];
    }
    stk.push(s);
    cout << stk.size() << "\n";
    while (!stk.empty()) {
      cout << stk.top() << " ";
      stk.pop();
    }
    exit(0);
  }
}
int main() {
  int n, m, k, i, l, r;
  cin >> n >> m >> k;
  for (i = 1; i <= m; ++i) {
    cin >> l >> r;
    adj[l].push_back(r);
    adj[r].push_back(l);
  }
  pi[1] = -1;
  dfs(1);
  return 0;
}
