#include <bits/stdc++.h>

int N, M;
std::vector <int> edge[110000];
int s, t;
bool vis[110000];
std::vector <int> ex1, ex2;

void expand (int u, std::vector <int> &ex) {
	ex.push_back (u);
	for (int i : edge[u]) {
		if (vis[i] == false) {
			vis[i] = true;
			expand (i, ex);
			return;
		}
	}
	return;	
}

int main () {
	std::ios::sync_with_stdio (0);
	std::cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int u, v;
		std::cin >> u >> v;
		edge[u].push_back (v);
		edge[v].push_back (u);
		s = u; t = v;
	}
	vis[s] = vis[t] = true;
	expand (s, ex1);
	expand (t, ex2);
	std::reverse (ex1.begin (), ex1.end ());
	std::cout << ex1.size () + ex2.size () << std::endl;
	for (int i : ex1) std::cout << i << " ";
	for (int i : ex2) std::cout << i << " ";	
}
