#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <fstream>

using namespace std;
// 5--9, 11, 12

vector<vector<int> > g;
vector<int> used;
int revision;
vector<int> cycle;
int cycleSize;
vector<int> level;
bool take;
int need;

bool dfs(int v, int d = 0)
{
    used[v] = revision;
    level[v] = d;
    for (int i = 0; i < g[v].size(); i++)
    {
        int to = g[v][i];
        if (used[to] == revision && level[to] != level[v] - 1)
        {
            take = true;
            need = to;
            cycle.push_back(v);
            return true;
        }
        if (used[to] == revision)
            continue;
        if (dfs(to, d + 1))
        {
            if (take)
                cycle.push_back(v);
            if (v == need)
                take = false;
            return true;
        }
    }
    return false;
}

int main()
{
    ifstream in("doggy.in");
    ofstream out("doggy.out");
    int n, m;
    in >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        in >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    vector<int> perm;
    for (int i = 0; i < n; i++)
        perm.push_back(i);
    random_shuffle(perm.begin(), perm.end());
    used = vector<int>(n);
    level = vector<int>(n);
    revision = 1;
    vector<int> best;
    for (int IT = 0; IT < 50; IT++)
    {
        revision++;
        random_shuffle(perm.begin(), perm.end());
        for (int i = 0; i < n; i++)
            random_shuffle(g[i].begin(), g[i].end());
        for (int i = 0; i < n; i++)
        {
            int v = perm[i];
            if (used[v] != revision)
            {
                cycle.clear();
                if (dfs(v))
                {
                    if (cycle.size() > best.size())
                        best = cycle;
                    break;
                }
            }
        }
    }
    out << best.size() << "\n";
    for (int i = 0; i < best.size(); i++)
        out << (best[i] + 1) << " ";
    out << "\n";
}
