#include <bits/stdc++.h>
using namespace std;
void FastIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
vector<int> path, marked;
vector<vector<int> > V;
void dfs(int u) {
  marked[u] = 1;
  path.push_back(u);
  for (int i = 0; i < V[u].size(); i++) {
    int v = V[u][i];
    if (!marked[v]) {
      dfs(v);
      break;
    }
  }
}
int main() {
  FastIO();
  int n, m, k, a, b, r = -1;
  cin >> n >> m >> k;
  marked.assign(n + 1, 0);
  V.assign(n + 1, vector<int>());
  for (int i = 0; i < (int)m; i++) {
    cin >> a >> b;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  dfs(1);
  int u = path.back();
  for (int i = path.size() - k - 1; i >= 0; i--) {
    cerr << "path[i]"
         << ": " << path[i] << '\n';
    ;
    for (int j = 0; j < V[u].size(); j++) {
      int v = V[u][j];
      if (v == path[i]) {
        cerr << "u"
             << ": " << u << " | "
             << "v"
             << ": " << v << '\n';
        ;
        r = path.size() - i;
        break;
      }
    }
    if (r > 0) break;
  }
  cout << r << '\n';
  for (int i = 0; i < r; i++) {
    cout << path.back() << " ";
    path.pop_back();
  }
  cout << '\n';
  return 0;
}
