#include <bits/stdc++.h>
using namespace std;
int N, M, a, b; bool vis[100009]; vector<int> g[100009];
int main() {
	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		cin >> a >> b; a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> ret = { 0 };
	int pos = 0; vis[0] = true;
	while(true) {
		bool f = false;
		for(int i : g[pos]) {
			if(!vis[i]) {
				f = true;
				vis[i] = true;
				ret.push_back(i);
				pos = i;
				break;
			}
		}
		if(!f) break;
	}
	reverse(ret.begin(), ret.end());
	pos = 0;
	while(true) {
		bool f = false;
		for(int i : g[pos]) {
			if(!vis[i]) {
				f = true;
				vis[i] = true;
				ret.push_back(i);
				pos = i;
				break;
			}
		}
		if(!f) break;
	}
	cout << ret.size() << endl;
	for(int i : ret) cout << i + 1 << ' ';
	return 0;
}