#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+3;
vector<int> v[N];
bool vis[N];
list<int> L;
int n,m;
void dfs(int u, bool ok){
	for(int i=0; i<v[u].size(); ++i){ 
		if(!vis[v[u][i]]){
			if(ok) L.push_front(v[u][i]);
			else L.push_back(v[u][i]);
			vis[v[u][i]] = true;
			dfs(e,ok);
			return;
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	memset(vis,false,sizeof(vis));
	while(m--){
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	L.push_back(1);
	L.push_back(v[1][0]);
	vis[1]=vis[v[1][0]]=true;
	dfs(1,true);
	dfs(v[1][0], false);
	printf("%d\n",L.size());
	for(auto it=L.begin(); it!=L.end(); ++it)
		printf("%d ",*it);
	printf("\n");
	return 0;
}