#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e5 + 10;
int k;
vector<int> g[maxn], cur;
int used[maxn];
void dfs(int v) {
  for (int i = 0; i < (int)(g[v]).size(); i++) {
    int to = g[v][i];
    if (used[to] != -1 && (int)(cur).size() - used[to] > k) {
      cout << (int)(cur).size() - used[to] << endl;
      for (int i = used[to]; i < (int)(cur).size(); i++) {
        cout << cur[i] + 1 << " ";
      }
      exit(0);
    } else if (used[to] == -1) {
      used[to] = (int)(cur).size();
      cur.push_back(to);
      dfs(to);
      used[to] = -1;
      cur.pop_back();
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  memset(used, -1, sizeof(used));
  for (int i = 0; i < n; i++) {
    used[i] = 0;
    cur.push_back(i);
    dfs(i);
    used[i] = -1;
    cur.pop_back();
  }
  return 0;
}
