//AtCoder
//(2368) AGC013B Hamiltonish Path

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

const int MAXN=100000+10;
vector<int> edge[MAXN];
bool vis[MAXN];
vector<int> path1,path2;
int n,m;

void dfs(int t)
{
	vis[t]=true;
	path1.push_back(t);
	
	for(int i=0;i<edge[t].size();++i)
	{
		if(!vis[edge[t][i]])
		{
			dfs(edge[t][i]);
			return;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<m;++i)
	{
		int x,y;
		cin>>x>>y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	
	dfs(1);
	swap(path1,path2);
	dfs(1);
	
	cout<<path1.size()+path2.size()-1<<endl;
	for(int i=path2.size()-1;i>=1;--i)
	{
		cout<<path2[i]<<' ';
	}
	for(int i=0;i<path1.size();++i)
	{
		cout<<path1[i]<<' ';
	}
	cout<<endl;
	
	return 0;
}