#include <bits/stdc++.h>
using namespace std;
vector<int> road[100011];
int n, m, k;
int vis[100111];
int line[100111];
bool dfs(int p, int d) {
  if (d > k && line[p]) {
    printf("%d\n", d);
    return 1;
  }
  for (int i = 0; i < road[p].size(); i++) {
    if (!vis[road[p][i]]) {
      vis[road[p][i]] = 1;
      if (dfs(road[p][i], d + 1)) {
        printf("%d ", road[p][i]);
        return 1;
      }
      break;
    }
  }
  return 0;
}
int main() {
  while (scanf("%d%d%d", &n, &m, &k) > 0) {
    for (int i = 0; i < m; i++) {
      int t1, t2;
      scanf("%d%d", &t1, &t2);
      road[t1].push_back(t2);
      road[t2].push_back(t1);
    }
    memset(vis, 0, sizeof(vis));
    ;
    for (int i = 1; i <= n; i++)
      if (!vis[i]) {
        vis[i] = 1;
        memset(line, 0, sizeof(line));
        ;
        for (int j = 0; j < road[i].size(); j++) line[road[i][j]] = 1;
        if (dfs(i, 1)) {
          printf("%d", i);
          break;
        }
      }
  }
  return 0;
}
