#include <bits/stdc++.h>
using namespace std;
vector<int> g[100010];
vector<int> ans;
int pos[100010];
int main(int argc, char const *argv[]) {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int p, q;
    cin >> p >> q;
    g[p].push_back(q);
    g[q].push_back(p);
  }
  memset(pos, -1, sizeof pos);
  int now = 1;
  pos[1] = 0;
  ans.push_back(1);
  while (1) {
    bool found = false;
    for (auto i : g[now]) {
      if (pos[i] == -1) {
        pos[i] = ans.size();
        ans.push_back(i);
        now = i;
        found = true;
        break;
      }
    }
    if (not found) break;
  }
  int start = ans.size();
  for (auto i : g[now]) start = min(start, pos[i]);
  cout << (int(ans.size()) - start) << endl;
  for (auto i = start; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
