#include <bits/stdc++.h>
using namespace std;

const int N = 100050;

int n, m;
vector<int> G[N];
bool del[N];

int find(int u) {
	while(!G[u].empty()) {
		int v = G[u].back(); G[u].pop_back(); if (del[v]) continue;
		return v;
	}
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	while(m--) {
		int u, v; cin >> u >> v;
		G[u].push_back(v); G[v].push_back(u);
	}
	del[1] = 1;
	deque<int> q; q.push_back(1);

	while(true) {
		int u, v;
		u = q.front();
		v = find(u);
		if (v != 0) { del[v] = 1; q.push_front(v); continue; }

		u = q.back();
		v = find(u);
		if (v != 0) { del[v] = 1; q.push_back(v); continue; }
		break;
	}

	printf("%d\n", (int)q.size());
	while(!q.empty()) {
		int u = q.front(); q.pop_front();
		printf("%d ", u);
	}
	printf("\n");
}