#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
int f[MAXN*2],n,m,vis[MAXN];
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
int check(int u)
{
	for(int i=Adj[u];i;i=nxt[i])
		if(!vis[V[i]])
			return V[i];
	return -1;
}
int main()
{
	int u,v;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	int l=MAXN,r=MAXN+1;
	f[MAXN]=u,f[MAXN+1]=v;
	vis[u]=vis[v]=1;
	while(1)
	{
		u=check(f[l]);
		if(u==-1) break;
		vis[u]=1;
		f[--l]=u;
	}
	while(1)
	{
		u=check(f[r]);
		if(u==-1) break;
		vis[u]=1;
		f[++r]=u;
	}
	printf("%d\n%d",r-l+1,f[l]);
	for(int i=l+1;i<=r;i++)
		printf(" %d",f[i]);
	printf("\n");
}