#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, k, dis[N], max_dis, dad[N], length = 1, cycle;
vector<int> adj[N], ans;
bool seen[N], way[N];
void DFS(int v) {
  seen[v] = true;
  for (int i = 0; i < adj[v].size(); i++)
    if (!seen[adj[v][i]]) {
      dis[adj[v][i]] = dis[v] + 1;
      max_dis = (dis[max_dis] > dis[v] + 1 ? max_dis : adj[v][i]);
      dad[adj[v][i]] = v;
      DFS(adj[v][i]);
    }
  return;
}
int main() {
  cin >> n >> m >> k;
  k++;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  DFS(0);
  ans.push_back(max_dis);
  for (int i = 0; i < adj[max_dis].size(); i++) way[adj[max_dis][i]] = true;
  cycle = max_dis;
  while (true) {
    ans.push_back(dad[cycle]);
    length++;
    cycle = dad[cycle];
    if (length >= k && way[cycle]) break;
  }
  cout << length << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
  return 0;
}
