#include <bits/stdc++.h>
using namespace std;

const int N = 100000 + 10;

int n, m;
vector<int> g[N];
vector<int> path[2];
bool vis[N];

void dfs( int u, vector<int> &path ) {
	path.push_back(u);
	for( int t = 0; t < (int)g[u].size(); t++ ) {
		int v = g[u][t];
		if( vis[v] ) continue;
		vis[v] = true;
		dfs( v, path );
		return;
	}
}
int main() {
	scanf( "%d%d", &n, &m );
	for( int i = 1; i <= m; i++ ) {
		int u, v;
		scanf( "%d%d", &u, &v );
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vis[1] = true;
	dfs( 1, path[0] );
	dfs( 1, path[1] );
	reverse( path[1].begin(), path[1].end() );
	path[1].pop_back();
	printf( "%d\n", path[0].size() + path[1].size() );
	for( int c = 1; c >= 0; c-- ) {
		for( int t = 0; t < path[c].size(); t++ )
			printf( "%d%s", path[c][t], c == 0 && t + 1== path[c].size() ? "\n" : " " );
	}
}


