#include<bits/stdc++.h>
using namespace std;
#define ran 111111
int n;
vector<int> e[ran];
bool f[ran];
int p1[ran],lp1;
int p2[ran],lp2;
void expand(int*p,int&l){
	while(true){
		int x = p[l-1];
		bool flag = true;
		for(vector<int>::iterator it = e[x].begin(); it!=e[x].end(); it++){
			int y = *it;
			if(f[y])continue;
			p[l++] = y;
			f[y] = true;
			flag = false;
			break;
		}
		if(flag)break;
	}
}
int main(){
	int x,y,m;
	scanf("%d%d",&n,&m);
	while(m--){
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	p1[lp1++] = x;
	p2[lp2++] = y;
	f[x] = f[y] = true;
	expand(p1, lp1);
	expand(p2, lp2);
	printf("%d\n",lp1+lp2);
	for(int i=lp1-1; i>=0; i--)
		printf("%d ",p1[i]);
	for(int i=0; i<lp2; i++)
		printf("%d%c",p2[i],i<lp2-1?' ':'\n');
	return 0;
}
