#include <bits/stdc++.h>
using namespace std;
int n,m;
vector <int> g[100010];
vector <int> path;
vector <int> path2;
int vis[100010];
void dfs(int t)
{
	path.push_back(t);
	vis[t]=1;
	for(int i=0;i<g[t].size();i++)
	{
		int nxt=g[t][i];
		if(!vis[nxt])
		{
			dfs(nxt);
			return;
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1);
	swap(path,path2);
	dfs(1);
	cout<<path.size()+path2.size()-1<<"\n";
	for(int i=path2.size()-1;i>=1;i--)
		cout<<path2[i]<<" ";
	for(int i=0;i<path.size();i++)
		cout<<path[i]<<" ";
	return 0;
}