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

constexpr int maxn = 1e5 + 100;

int n, m;
vector<int> vec[maxn]= {}, path;
bitset<maxn> viz = 0;

bool extend_path(){
    const int cur = path.back();
    while(!vec[cur].empty() && viz[vec[cur].back()]) vec[cur].pop_back();
    if(vec[cur].empty()) return false;
    viz[vec[cur].back()] = 1;
    path.push_back(vec[cur].back());
    return true; }

int main(){
    cin >> n >> m;
    for(int i = 0, a, b; i < m; ++i){
        cin >> a >> b;
        vec[a].push_back(b);
        vec[b].push_back(a); }
    path.push_back(1);
    path.push_back(vec[1][0]);
    viz[1] = viz[vec[1][0]] = 1;
    while(extend_path());
    reverse(begin(path), end(path));
    while(extend_path());
    cout << path.size() << endl;
    for(const auto x : path) cout << x << ' ';
    cout << endl;
    return 0; }
