#include <bits/stdc++.h>
using namespace std;
long long v, e, k, from, to, start = 0, End = 0, res = 0;
map<long long, vector<long long>> adj;
vector<long long> vis(200010), len(200010);
map<long long, long long> parent;
void dfs(long long node, long long level) {
  len[node] = level;
  vis[node] = 1;
  for (int i = 0; i < adj[node].size(); i++) {
    long long child = adj[node][i];
    if (vis[child] && level - len[child] >= k) {
      start = child;
      End = node;
      parent[child] = node;
    }
    if (!vis[child] && start + End == 0) {
      dfs(child, level + 1);
      parent[child] = node;
    }
  }
}
void print_path(long long start, long long End) {
  cout << End << " ";
  if (End == start) return;
  print_path(start, parent[End]);
}
int main() {
  cin >> v >> e >> k;
  for (int i = 1; i <= e; i++) {
    cin >> from >> to;
    adj[from].push_back(to);
    adj[to].push_back(from);
  }
  dfs(1, 0);
  cout << len[End] - len[start] + 1 << endl;
  print_path(start, End);
  return 0;
}
