//Code by Lucida
#include<bits/stdtr1c++.h>
typedef long long int64;
namespace IO {
#ifdef OI
	const int IN=1e7;
	char in[IN],*ip=in,*ie=in;
	#define getchar() ( (ip==ie && (ie=(ip=in)+fread(in,1,IN,stdin),ip==ie))?EOF:*ip++ )
#endif
	struct Ist {
		template <class T> Ist &operator >>(T &x);
		template <class T> Ist &operator >>(T *x);
		operator bool() const {return feof(stdin);}
	}is;
	template <class T> Ist &Ist::operator >>(T &x) {
		static bool f;static char ch;
		for(f=0,ch=0;ch<'0' || '9'<ch;ch=getchar()) f|=ch=='-';
		for(x=0;'0'<=ch && ch<='9';ch=getchar()) (x*=10)+=ch-'0';
		x=f?-x:x;
		return *this;
	}
	template <class T> Ist &Ist::operator >>(T *x) {
		while(*x=getchar(),(*x==' ' || *x=='\r' || *x=='\n' || *x==EOF));
		x++;
		while(*x=getchar(),(*x!=' ' && *x!='\r' && *x!='\n' && *x!=EOF))
			x++;
		*x=0;
		return *this;
	}
	template <> Ist &Ist::operator >>(double &x) {
		scanf("%lf",&x);
		return *this;
	}
	template <> Ist &Ist::operator >>(char &x) {
		while(x=getchar(),x=='\n' || x=='\r' || x==' ');
		return *this;
	}
#ifdef OO
	const int OUT=1e7;
	char out[OUT],*op=out,*oe=out+OUT;
	#define flush() (fwrite(out,1,op-out,stdout))
	#define putchar(x) ((op==oe?(flush(),*op++):*op++)=(x) )
#endif
	struct Ost {
		char doubleFormat[10];
		Ost() {
			sprintf(doubleFormat,"%%lf");
		}
#ifdef OO
		~Ost() {
			flush();
		}
#endif
		void precision(const int &a) {
			sprintf(doubleFormat,"%%.%dlf",a);
		}
		template <class T> Ost &operator <<(T x);
		template <class T> Ost &operator <<(T *x);

	}os;
	template <class T> Ost &Ost::operator <<(T x) {
		if(!x)
			putchar('0');
		else {
			if(x<0) putchar('-'),x=-x;
			static char stack[30]={0};
			char *top=stack;
			for(;x;x/=10) *++top=x%10+'0';
			while(*top) putchar(*top--);
		}
		return *this;
	}
	template <class T> Ost &Ost::operator <<(T* x) {
		while(*x) putchar(*x++);
		return *this;
	}
	template <>	Ost &Ost::operator <<(double x) {
		printf(doubleFormat,x);
		return *this;
	}
	template <> Ost &Ost::operator <<(char x) {
		putchar(x);
		return *this;
	}
}

template <class T> inline bool chkmx(T &a,const T &b) {return a<b?a=b,1:0;}
template <class T> inline bool chkmn(T &a,const T &b) {return a>b?a=b,1:0;}
template <class T,class C> inline T &operator +=(T &a,const C &b) {return a=a+b;}
template <class T,class C> inline T &operator -=(T &a,const C &b) {return a=a-b;}
template <class T,class C> inline T &operator *=(T &a,const C &b) {return a=a*b;}
template <class T,class C> inline T &operator /=(T &a,const C &b) {return a=a/b;}

using IO::is;
using IO::os;

#define alloc(T,c) (T*)malloc((c)*sizeof(T))
#define pass void(0)
#define import using std::
#define array std::vector

const int MAXN=1e5+11;
struct Edge {
	int to;Edge *pre;
	Edge(int to,Edge *pre):to(to),pre(pre) {}
}*G[MAXN];
void Adde(int f,int t) {
	G[f]=new Edge(t,G[f]);
	G[t]=new Edge(f,G[t]);
}
bool ud[MAXN];
void BFS(int s,std::vector<int> &path) {
	std::queue<int> Q;
	Q.push(s);ud[s]=1;
	while(!Q.empty()) {
		int pos=Q.front();Q.pop();path.push_back(pos);
		for(Edge *e=G[pos];e;e=e->pre) if(!ud[e->to]) {
			Q.push(e->to);
			ud[e->to]=1;
			break;
		}
	}
}
int main() {
//	freopen("input","r",stdin);
	int n,m;is>>n>>m;
	for(int i=1;i<=m;++i) {
		int x,y;is>>x>>y;
		Adde(x,y);
	}
	std::vector<int> path;
	int cnt=0;
	ud[1]=1;
	for(Edge *e=G[1];e;e=e->pre) if(!ud[e->to]) {
		BFS(e->to,path);
		if(++cnt==1) {
			std::reverse(path.begin(),path.end());
			path.push_back(1);
		} else {
			break;
		}
	}
	os<<path.size()<<'\n';
	for(int i=0;i<path.size();++i) {
		os<<path[i]<<(i==path.size()-1?'\n':' ');
	}
	return 0;
}



Measured memory_bytes: 8444