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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
inline int ctoi(char c) {if (c >= '0' && c <= '9') return (int)(c - '0'); return -1;}
inline int uatoi(char c) {if (c >= 'A' && c <= 'Z') return (int)(c - 'A'); return -1;}
inline int latoi(char c) {if (c >= 'a' && c <= 'z') return (int)(c - 'a'); return -1;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class UnionFind {
    vector<int> parent;

    public:
        UnionFind(int size) {
            parent = vector<int>(size, -1);
        }

        int find(int x) {
            if (parent[x] < 0) {
                // parent itself
                return x;
            } else {
                return parent[x] = find(parent[x]);
            }
        }

        bool unite(int x, int y) {
            int rX, rY;
            if ((rX = find(x)) == (rY = find(y))) {
                // already united
                return false;
            }
            if (size(rX) < size(rY)) {
                int tmp = rX;
                rX = rY;
                rY = tmp;
            }
            parent[rX] += parent[rY];
            parent[rY] = rX;
            return true;
        }

        int size(int x) {
            return -parent[find(x)];
        }

        bool is_same(int x, int y) {
            return find(x) == find(y);
        }

        int component_count() {
            int c = 0;
            for (const int x : parent) {
                if (x < 0) {
                    c++;
                }
            }
            return c;
        }
};

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n, vector<int>());
    int a, b;
    REP(i, m) {
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    vector<bool> visited(n, false);
    vector<int> ans;
    function<bool(int, int)> dfs = [&](int c, int p) {
        visited[c] = true;
        if (p != -1 && sz(g[c]) == 1) {
            ans.emplace_back(c);
            return true;
        }

        bool de = true;
        for (int x : g[c]) {
            if (visited[x]) continue;
            de = false;
            if (dfs(x, c)) {
                ans.emplace_back(c);
                return true;
            }
        }
        if (de) {
            ans.emplace_back(c);
            return true;
        }
        return false;    
    };

    dfs(0, -1);
    vector<int> ans2(sz(ans));
    copy(ALL(ans), ans2.begin());
    ans.clear();
    for (int x : g[0]) if (!visited[x]) {
        dfs(x, 0);
        break;
    }
    // reverse(ALL(ans));
    reverse(ALL(ans2));
    cout << sz(ans) + sz(ans2) << EOL;
    REP(i, sz(ans)) cout << ans[i] + 1 << EOL;
    REP(i, sz(ans2)) cout << ans2[i] + 1 << EOL;
}



Measured memory_bytes: 14328