#include <iostream>
#include <vector>
using namespace std;
const int maxn = 1e5+10;
vector<int> v[maxn];
bool vis[maxn];
int a[maxn], num;
void d(int x){
	for(int i = 0; i < v[x].size(); ++i){
		int xx = v[x][i];
		if(vis[xx]) continue;
		vis[xx] = true, a[++num] = xx;
		d(xx); return ;
	}
}
int main(){
	int n, m, x, y, num2;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; ++i){
		scanf("%d%d", &x, &y);
		v[x].push_back(y), v[y].push_back(x);
	}
	vis[1] = true;
	a[num = 1] =  1;
	d(1),  num2 = num, d(1);
	printf("%d\n", num);
	for(int i = num2; i >= 1; --i){
		if(i == num2) printf("%d", a[i]);
		else printf(" %d", a[i]);
	}
	for(int i = num2+1; i <= num; ++i){
		printf(" %d", a[i]);
	}
	printf("\n");
	return 0;
}