#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const long long LINF = LLONG_MAX;
const int N = 1e5 + 20;
vector<int> G[N], p;
int n, m, k, f[N], tmp;
bool visited[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 0, v, u; i < m; i++) {
    cin >> v >> u;
    G[v].push_back(u);
    G[u].push_back(v);
  }
  int v = 1;
  while (1) {
    visited[v] = 1;
    f[v] = tmp++;
    p.push_back(v);
    for (int u : G[v])
      if (!visited[u]) v = u;
    if (visited[v]) break;
  }
  int idx = INF;
  for (int v : G[p.back()]) idx = min(idx, f[v]);
  cout << p.size() - idx << endl;
  for (int i = idx; i < p.size(); i++) cout << p[i] << ' ';
  cout << endl;
}
