#include <bits/stdc++.h>
using namespace std;
const uint64_t seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937_64 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const vector<pair<A, B>> &v)
{
    os << "{";
    for (typename vector<pair<A, B>>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << '(' << vi->first << " " << vi->second << ")";
    }
    os << "}";
    return os;
}

template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
using LL = long long;

class DSU
{
public:
    vector<int> pa;
    vector<int> cnt;
    int setCnt;

    DSU(int n) : pa(n), cnt(n), setCnt(n)
    {
        for (int i = 0; i < n; i++)
        {
            pa[i] = i;
            cnt[i] = 1;
        }
    }

    int get(int a)
    {
        return pa[a] = (pa[a] == a ? a : get(pa[a]));
    }

    bool merge(int a, int b)
    {
        a = get(a);
        b = get(b);
        if (a != b)
        {
            setCnt--;
            if (cnt[a] > cnt[b])
                swap(a, b);
            pa[a] = b;
            cnt[b] += cnt[a];
            return true;
        }
        else
            return false;
    }
};

void solve(int caseNum)
{
    int n, m;
    cin >> n >> m;
    vector<unordered_set<int>> g(n);
    vector<pair<int, int>> edges;
    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].insert(v);
        g[v].insert(u);
        edges.push_back({u, v});
    }
    int initOddCnt = 0;
    for (int i = 0; i < n; i++)
        initOddCnt += g[i].size() % 2;
    for (int i = 0; i < n; i++)
    {
        int removeEdgeCnt = 0;
        DSU dsu(n);
        vector<bool> used(m, false);
        for (int j = 0; j < m; j++)
        {
            auto [u, v] = edges[j];
            if (v == i)
                swap(u, v);
            if (u == i && g[v].size() % 2 == 1)
            {
                removeEdgeCnt++;
                continue;
            }

            dsu.merge(u, v);
            used[j] = true;
        }
        int oddCnt = initOddCnt - removeEdgeCnt;
        if (g[i].size() % 2 == 1)
            oddCnt--;
        if (oddCnt > 1)
            continue;
        bool find = true;
        dbg(i, oddCnt);
        if (oddCnt == 1)
        {
            for (int j = 0; j < n; j++)
            {
                if (dsu.cnt[dsu.get(j)] >= 2 && dsu.get(j) != dsu.get(i))
                {
                    find = false;
                    break;
                }
            }
        }
        else
        {
            int f = false;
            for (int j = 0; j < m; j++)
            {
                if (used[j])
                    continue;
                auto [u, v] = edges[j];
                if (v == i)
                    swap(u, v);

                if (dsu.cnt[dsu.get(v)] >= 2 && dsu.get(v) != dsu.get(i))
                {
                    if (!f)
                    {
                        f = true;
                        used[j] = true;
                        removeEdgeCnt--;
                        oddCnt++;
                        dsu.merge(v, i);
                    }
                    else
                    {
                        find = false;
                        break;
                    }
                }
            }
        }
        if (find)
        {
            vector<vector<int>> gg(n);
            vector<int> remove(m, false);
            vector<int> path;
            for (int j = 0; j < m; j++)
            {
                if (used[j])
                {
                    auto [u, v] = edges[j];
                    gg[u].push_back(j);
                    gg[v].push_back(j);
                }
            }
            int start = i;
            for (int j = 0; j < n; j++)
            {
                if (j != i && gg[j].size() % 2 == 1)
                {
                    start = j;
                    break;
                }
            }
            vector<int> path1;
            vector<bool> vis(n, false);
            vector<bool> removed(m, false);
            function<bool(int)> dfs1 = [&](int p) {
                vis[p] = true;
                if (p == i)
                {
                    path1.push_back(p);
                    return true;
                }
                for (int e : gg[p])
                {
                    int v = edges[e].first ^ edges[e].second ^ p;
                    if (vis[v])
                        continue;
                    if (dfs1(v))
                    {
                        path1.push_back(p);
                        removed[e] = true;
                        return true;
                        break;
                    }
                }
                return false;
            };
            if (oddCnt > 0)
                dfs1(start);
            reverse(path1.begin(), path1.end());
            function<void(int)> dfs2 = [&](int p) {
                path.push_back(p);
                for (int k = gg[p].size() - 1; k >= 0; k--)
                {
                    int e = gg[p][k];
                    gg[p].pop_back();
                    if (removed[e])
                        continue;
                    removed[e] = true;
                    int v = edges[e].first ^ edges[e].second ^ p;
                    dfs2(v);
                    break;
                }
            };
            if (oddCnt > 0)
            {
                for (int p : path1)
                {
                    dfs2(p);
                }
            }
            else
                dfs2(i);

            while (path.size() != path1.size())
            {
                swap(path, path1);
                path.clear();
                for (int p : path1)
                {
                    dfs2(p);
                }
            }

            if (removeEdgeCnt > 0)
                path.push_back(-2);
            for (int j = 0; j < m; j++)
            {
                if (!used[j])
                {
                    auto [u, v] = edges[j];
                    if (v == i)
                        swap(u, v);
                    path.push_back(v);
                    path.push_back(u);
                }
            }
            cout << path.size() << "\n";
            for (int p : path)
                cout << p + 1 << " ";
            cout << "\n";
            return;
        }
    }

    cout << 0 << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve(i);
    }
    cout.flush();
    return 0;
}
