#include <bits/stdc++.h>
using namespace std;
int dis[100005];
vector<int> adj[100005], path;
void DFS(int u) {
  path.push_back(u);
  for (int i = 0; i < (adj[u].size()); i++) {
    int v = adj[u][i];
    if (dis[v] == -1) {
      dis[v] = dis[u] + 1;
      DFS(v);
      break;
    }
  }
  return;
}
int main() {
  int n, m, k, x, y;
  memset(dis, -1, sizeof(dis));
  scanf("%d %d %d", &n, &m, &k);
  while (m--) {
    scanf("%d %d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dis[1] = 0;
  DFS(1);
  int e = path.back(), s = adj[e][0];
  for (int i = 0; i < adj[e].size(); i++)
    if (dis[s] > dis[adj[e][i]]) s = adj[e][i];
  int id;
  for (int i = 0; i < path.size(); i++)
    if (path[i] == s) {
      id = i;
      break;
    }
  cout << path.size() - id << endl;
  printf("%d", s);
  for (int i = id + 1; i < path.size(); i++) printf(" %d", path[i]);
  printf("\n");
  return 0;
}
