// #pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <cmath>
#include <set>

using namespace std;

#define mp make_pair
#define ll long long
#define pb push_back

const int Max = 1001;

int ansSize = 0;
bool found = false;
int curr = 0;
int n, m;
int a[Max][Max];
int v[Max];
int d[Max];
vector<int> ans;

void findPath(int u) {
	if (found) {
		return;
	}

	d[u] = 1;
	ans.push_back(u);
	curr++;

	if (curr == ansSize) {
		if (a[u][0]) {
			found = true;
			return;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (a[u][i] && !d[i]) {
				findPath(i);
			}

			if (found) {
				return;
			}
		}
	}

	d[u] = 0;
	ans.pop_back();
	curr--;
}

void dfs(int u) {
	v[u] = 1;
	for (int i = 0; i < n; i++) {
		if (a[u][i] == 1 && v[i] == 0) {
			dfs(i);
		}
	}
}

int main() {
	scanf("%d %d", &n, &m);

	memset(a, 0, sizeof(a));
	for (int i = 0; i < m; i++) {
		int b, e;
		scanf("%d %d", &b, &e);
		a[b - 1][e - 1] = 1;
		a[e - 1][b - 1] = 1;
	}

	dfs(0);

	for (int i = 0; i < n; i++) {
		if (v[i]) ansSize++;
	}
	
	memset(d, 0, sizeof(d));
	findPath(0);

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] + 1 << ' ';
	}
	cout << endl;

	return 0;
}
/*
3 3
1 2
1 3
2 3

4 5
1 2
1 3
1 4
2 3
2 4
*/