#include <bits/stdc++.h>
using namespace std;
vector<int> tree[100001];
int depth[100001];
bool stat[100001];
int parent[100001][19];
map<pair<int, int>, int> trk;
void dfs(int cur, int prev) {
  if (cur > prev)
    trk[{prev, cur}]++;
  else
    trk[{cur, prev}]++;
  stat[cur] = true;
  depth[cur] = depth[prev] + 1;
  parent[cur][0] = prev;
  for (int i = 0; i < tree[cur].size(); i++) {
    if (tree[cur][i] != prev && stat[tree[cur][i]] == false)
      dfs(tree[cur][i], cur);
  }
}
void precomputeSparseMatrix(int n) {
  for (int i = 1; i < 19; i++) {
    for (int node = 1; node <= n; node++) {
      if (parent[node][i - 1] != -1)
        parent[node][i] = parent[parent[node][i - 1]][i - 1];
    }
  }
}
int lca(int u, int v) {
  if (depth[v] < depth[u]) swap(u, v);
  int diff = depth[v] - depth[u];
  for (int i = 0; i < 19; i++) {
    if ((diff >> i) & 1) {
      v = parent[v][i];
    }
  }
  if (u == v) return u;
  for (int i = 19 - 1; i >= 0; i--)
    if (parent[u][i] != parent[v][i]) {
      u = parent[u][i];
      v = parent[v][i];
    }
  return parent[u][0];
}
void addEdge(int u, int v) {
  tree[u].push_back(v);
  tree[v].push_back(u);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(parent, -1, sizeof(parent));
  memset(stat, false, sizeof(stat));
  depth[0] = 0;
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    addEdge(u, v);
  }
  dfs(1, 0);
  precomputeSparseMatrix(n);
  int size, fg = 0, f1, f2;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < tree[i].size(); j++) {
      if (!trk[{min(i, tree[i][j]), max(i, tree[i][j])}]) {
        int ll = lca(i, tree[i][j]);
        size = depth[i] + depth[tree[i][j]] - (depth[ll] - 1) * 2 - 1;
        if (size > k) {
          f1 = i;
          f2 = tree[i][j];
          fg = 1;
          break;
        }
      }
    }
    if (fg) break;
  }
  int f3 = lca(f1, f2);
  if (depth[f1] > depth[f2]) swap(f1, f2);
  vector<int> path, path2;
  int x = f1;
  while (x != f3) {
    path.push_back(x);
    x = parent[x][0];
  }
  path.push_back(f3);
  x = f2;
  while (x != f3) {
    path2.push_back(x);
    x = parent[x][0];
  }
  cout << path.size() + path2.size() << "\n";
  reverse(path2.begin(), path2.end());
  for (int i = 0; i < path.size(); i++) cout << path[i] << " ";
  for (int i = 0; i < path2.size(); i++) cout << path2[i] << " ";
  return 0;
}
