#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

int n,m;
vector<int> g[100005];
bool vis[100005];
vector<int> p0,p1;

void dfs(int x, vector<int>& p){
	vis[x]=true;p.pb(x);
	for(int y:g[x])if(!vis[y]){dfs(y,p);return;}
}

int main(){
	scanf("%d%d",&n,&m);
	fore(i,0,m){
		int x,y;
		scanf("%d%d",&x,&y);x--;y--;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(0,p0);
	dfs(0,p1);
	reverse(p0.begin(),p0.end());
	for(int x:p1)if(x)p0.pb(x);
	printf("%d\n",(int)p0.size());
	fore(i,0,p0.size()){
		if(i)putchar(' ');
		printf("%d",p0[i]+1);
	}
	puts("");
	return 0;
}