#include<bits/stdc++.h>

using namespace std;

#define maxn 3010

int n, m;
int deg[maxn];
set<int> adj[maxn];
set<int> g[maxn];
vector<int> tmp;

void dfs(int u)
{
    while (g[u].size())
    {
        int v = *g[u].begin();
        g[u].erase(v);
        g[v].erase(u);
        dfs(v);
    }
    tmp.push_back(u);
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    memset(deg, 0, sizeof(deg));
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].insert(v);
        adj[v].insert(u);
        deg[u]++;
        deg[v]++;
    }

    for (int root = 1; root <= n; root++)
    {
        set<int> deleted;
        set<int> droot = adj[root];
        int tm = m;
        deleted.clear();
        for (auto v: droot)
        {
            if (deg[v] % 2 == 1)
            {
                adj[root].erase(v);
                adj[v].erase(root);
                deleted.insert(v);
                deg[v]--;
                deg[root]--;
                tm--;
            }
        }


        int cnt = 0;
        for (int i = 1; i <= n; i++)
            if (deg[i] % 2 == 1) cnt++;

        if (cnt == 0 || cnt == 2)
        {
            tmp.clear();
            for (int i = 1; i <= n; i++) g[i] = adj[i];
            dfs(root);
            bool ok = true;

            for (int i = 1; i <= n; i++) g[i] = adj[i];
            for (int i = 0; i < tmp.size() - 1; i++)
            {
                if (g[tmp[i]].count(tmp[i + 1]) == 0)
                {
                    ok = false;
                    break;
                }
                g[tmp[i]].erase(tmp[i + 1]);
                g[tmp[i + 1]].erase(tmp[i]);
            }

            if (ok)
            {
                if (tmp.size() - 1 == tm)
                {
                    if (deleted.size())
                    {
                        tmp.push_back(-1);
                        for (auto v: deleted)
                        {
                            tmp.push_back(v);
                            tmp.push_back(root);
                        }
                    }
                    cout << tmp.size() << endl;
                    for (auto x: tmp) cout << x << " ";
                    return 0;
                }
            }
        }


        droot = deleted;
        for (auto v: droot)
        {
            cnt = 0;
            adj[root].insert(v);
            adj[v].insert(root);
            deg[root]++;
            deg[v]++;
            tm++;
            deleted.erase(v);
            for (int i = 1; i <= n; i++)
                if (deg[i] % 2 == 1) cnt++;

            if (cnt == 0 || cnt == 2)
            {
                tmp.clear();
                for (int i = 1; i <= n; i++) g[i] = adj[i];
                dfs(root);

                bool ok = true;
                for (int i = 1; i <= n; i++) g[i] = adj[i];
                for (int i = 0; i < tmp.size() - 1; i++)
                {
                    if (g[tmp[i]].count(tmp[i + 1]) == 0)
                    {
                        ok = false;
                        break;
                    }
                    g[tmp[i]].erase(tmp[i + 1]);
                    g[tmp[i + 1]].erase(tmp[i]);
                }

                if (ok)
                {
                    if (tmp.size() - 1 == tm)
                    {
                        if (deleted.size())
                        {
                            tmp.push_back(-1);
                            for (auto v: deleted)
                            {
                                tmp.push_back(v);
                                tmp.push_back(root);
                            }
                        }
                        cout << tmp.size() << endl;
                        for (auto x: tmp) cout << x << " ";
                        return 0;
                    }
                }
            }
            adj[root].erase(v);
            adj[v].erase(root);
            deg[root]--;
            deg[v]--;
            tm--;
            deleted.insert(v);
        }

        droot = adj[root];
        for (auto v: droot)
        {
            cnt = 0;
            adj[root].erase(v);
            adj[v].erase(root);
            deg[root]--;
            deg[v]--;
            tm--;
            deleted.insert(v);
            for (int i = 1; i <= n; i++)
                if (deg[i] % 2 == 1) cnt++;

            if (cnt == 0 || cnt == 2)
            {
                tmp.clear();
                for (int i = 1; i <= n; i++) g[i] = adj[i];
                dfs(root);
                bool ok = true;
                for (int i = 0; i < tmp.size() - 1; i++)
                {
                    if (g[tmp[i]].count(tmp[i + 1]) == 0)
                    {
                        ok = false;
                        break;
                    }
                    g[tmp[i]].erase(tmp[i + 1]);
                    g[tmp[i + 1]].erase(tmp[i]);
                }

                if (ok)
                {
                    if (tmp.size() - 1 == tm)
                    {
                        if (deleted.size())
                        {
                            tmp.push_back(-1);
                            for (auto v: deleted)
                            {
                                tmp.push_back(v);
                                tmp.push_back(root);
                            }
                        }
                        cout << tmp.size() << endl;
                        for (auto x: tmp) cout << x << " ";
                        return 0;
                    }
                }
            }
            adj[root].insert(v);
            adj[v].insert(root);
            deg[root]++;
            deg[v]++;
            tm++;
            deleted.erase(v);
        }

        for (auto v: deleted)
        {
            adj[root].insert(v);
            adj[v].insert(root);
            deg[v]++;
            deg[root]++;
        }
    }

    cout << 0 << endl;
    return 0;
}
