#include <iostream>
#include <vector>
#include <fstream>
#include <memory.h>

using namespace std;

const int maxn = 1<<10;

int a[maxn][maxn];
vector<int> adj[maxn];

int next[maxn];
int prev[maxn];

int p[maxn];
int q[maxn];

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i=0; i<m; i++)
    {
        int x, y;
        cin >> x >> y;
        a[x][y] = a[y][x] = 1;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    if (adj[1].size() < 2)
    {
        cout << adj[1].size() + 1 << endl;
        cout << 1;
        if (adj[1].size())
            cout << " " << adj[1][0];
        cout << endl;
        return 0;
    }

    for (int i=0; i < adj[1].size(); i++)
        for (int j=0; j < i; j++)
            if (a[adj[1][i]][adj[1][j]])
            {
                next[1] = adj[1][i];
                next[adj[1][i]] = adj[1][j];
                next[adj[1][j]] = 1;

                prev[1] = adj[1][j];
                prev[adj[1][j]] = adj[1][i];
                prev[adj[1][i]] = 1;

                i = j = n;
            }

    int v;
    for (v = 3; v < n; v++)
    {
        int x = 0, y = 0;

        for (int i=1; i <= n; i++)
            if (next[i])
            {
                for (int j=0; j < adj[i].size(); j++)
                    if (!next[adj[i][j]])
                    {
                        y = i;
                        x = adj[i][j];
                    }
            }

        if (!x)
            break;

        memset(p, 0, sizeof(p));

        int qs = 0, qf = 0;
        q[qf++] = next[y];
        p[next[y]] = next[y];
        p[y] = y;

        for (; ; qs++)
        {
            int z = q[qs];
            for (int i=0; i < adj[z].size(); i++)
                if (a[adj[z][i]][y] && !p[adj[z][i]])
                {
                    p[adj[z][i]] = z;

                    if (!next[adj[z][i]])
                    {
                        x = adj[z][i];
                        break;
                    }

                    q[qf++] = adj[z][i];
                }

            if (p[x])
                break;
        }

        if (a[x][next[y]])
        {
            next[x] = next[y];
            next[y] = x;
            prev[x] = y;
            prev[next[x]] = x;

            continue;
        }

        if (a[x][prev[y]])
        {
            prev[x] = prev[y];
            prev[y] = x;
            next[x] = y;
            next[prev[x]] = x;
            continue;
        }

        vector<int> path;
        for (; x != next[y]; x = p[x])
            path.push_back(x);
        path.push_back(next[y]);

        prev[next[y]] = prev[y];
        next[prev[y]] = next[y];

        for (int i=0; ; i++)
        {
            if (i)
            {
                prev[next[path[i]]] = prev[path[i]];
                next[prev[path[i]]] = next[path[i]];
            }

            if (a[path[i]][next[path[i+1]]])
            {
                int t = next[path[i+1]];
                for (int j=0; j < i; j++)
                {
                    next[path[j]] = path[j+1];
                    prev[path[j+1]] = path[j];
                }
                next[path[i]] = t;
                prev[t] = path[i];

                next[y] = path[0];
                prev[path[0]] = y;

                next[path[i+1]] = y;
                prev[y] = path[i+1];
                break;
            }

            if (a[path[i]][prev[path[i+1]]])
            {
                int t = prev[path[i+1]];
                for (int j=0; j < i; j++)
                {
                    prev[path[j]] = path[j+1];
                    next[path[j+1]] = path[j];
                }
                prev[path[i]] = t;
                next[t] = path[i];

                prev[y] = path[0];
                next[path[0]] = y;

                prev[path[i+1]] = y;
                next[y] = path[i+1];
                break;
            }
        }
    }

    cout << v << endl;

    for (int i=1; ; )
    {
        cout << i << " ";
        i = next[i];
        if (i == 1)
            break;
    }
    cout << endl;

    return 0;
}
