#include <bits/stdc++.h>
using namespace std;
vector<int> a[int(1e5) + 20];
bool used[int(1e5) + 20];
int x, y, tin[int(1e5) + 20], p[int(1e5) + 20], n, m, k, timer;
void dfs(int v, int pr) {
  used[v] = 1;
  tin[v] = timer++;
  p[v] = pr;
  for (int i = 0; i < a[v].size(); i++) {
    int to = a[v][i];
    if (used[to]) {
      if (tin[v] - tin[to] >= k) {
        cout << tin[v] - tin[to] + 1 << endl;
        int q = v;
        while (q != to) {
          cout << q << " ";
          q = p[q];
        }
        cout << q;
        exit(0);
      }
      continue;
    }
    dfs(to, v);
  }
}
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);
  }
  for (int i = 1; i <= n; i++)
    if (!used[i]) dfs(i, -1);
  return 0;
}
