#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <bitset>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <ctime>
#include <chrono>


/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else
    #define dbg(x)
#endif

#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define fk(a, b) for (int k = a; k < b; k++)
#define fi1(a, b) for (int i = a - 1; i >= b; i--)
#define fj1(a, b) for (int j = a - 1; j >= b; j--)
#define fk1(a, b) for (int k = a - 1; k >= b; k--)
#define fx(x, a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define left leftkekmda
#define right rightkekmda

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, const T2 &y) { if (y < x) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, const T2 &y) { if (x < y) x = y; }

template<typename T> ostream& operator << (ostream &os, const vector<T> &b) {
    for (auto &k : b) os << k << ' ';
    return os;
}
template<typename T> istream& operator >> (istream &is, vector<T> &b) {
    for (auto &k : b) is >> k;
    return is;
}


typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



const int N = 3010;
int n, m;
namespace dsu {
    int p[N];
    int sz[N];
    int eds[N];
    int cnt;
    struct inf {
        int a;
        int b;
        int pra;
        int prb;
        int sza;
        int szb;
        int ea;
        int eb;
        int pcnt;
        inf (int _a, int _b, int _pcnt) {
            a = _a;
            ea = eds[a];
            pra = p[a];
            sza = sz[a];
            b = _b;
            eb = eds[b];
            prb = p[b];
            szb = sz[b];
            pcnt = _pcnt;
        }
    };
    vector<inf> pers;
    void init() {
        for (int i = 0; i < n; ++i) {
            p[i] = i;
            sz[i] = 1;
            eds[i] = 0;
        }
        cnt = 0;
    }
    int get(int v) {
        if (p[v] == v)
            return v;
        return get(p[v]);
    }
    void unite(int a, int b) {
        //dbg(cnt);
        //cout << "unite: " << a << ' ' << b << '\n';
        a = get(a);
        b = get(b);
        pers.pb(inf(a, b, cnt));
        if (a == b) {
            cnt += eds[a] == 0;
            eds[a]++;
            return;
        }
        if (sz[a] < sz[b]) swap(a, b);
        cnt -= eds[a] > 0;
        cnt -= eds[b] > 0;
        p[b] = a;
        sz[a] += sz[b];
        eds[a] += eds[b] + 1;
        ++cnt;
    }
    void rollback() {
        inf i = pers.back();
        //cout << "split: " << i.a << ' ' << i.b << '\n';
        sz[i.a] = i.sza;
        p[i.a] = i.pra;
        eds[i.a] = i.ea;
        sz[i.b] = i.szb;
        p[i.b] = i.prb;
        eds[i.b] = i.eb;
        
        cnt = i.pcnt;
        //dbg(cnt);
        pers.ppb;
    }
}

vpii dcp[4 * N];

void add(int v, int l, int r, pii edge, int cl, int cr) {
    if (cl >= r || cr <= l)
        return;
    if (cl >= l && cr <= r) {
        dcp[v].pb(edge);
        return;
    }
    int mid = (cl + cr) / 2;
    add(2 * v, l, r, edge, cl, mid);
    add(2 * v + 1, l, r, edge, mid, cr);
}

vi g[N];
bool c[N][N];
vi odd[N];
vi eul;
void dfs(int v, int start, const vch & ban) {
    while (g[v].size()) {
        int to = g[v].back();
        g[v].ppb;
        if (!c[v][to] || (v == start && ban[to]) || (ban[v] && to == start)) continue;
        c[v][to] = c[to][v] = 0;
        dfs(to, start, ban);
    }
    eul.pb(v);
}

void check(int v) {
    int r = -1;
    for (int i = 0; i < n; ++i) {
        if (i != v && !c[v][i] && g[i].size() % 2) {
            if (r != -1)
                return;
            r = i;
        }
    }
    //dbg(dsu::cnt);
    auto con = [&]() {
        return dsu::cnt == 0 || (dsu::cnt == 1 && dsu::eds[dsu::get(v)] > 0);
    };
    //dbg(v);
    //dbg(r);
    //dbg(odd[v]);
    int skip = -1;
    vch ban(n, 0);
    fx(to, odd[v]) ban[to] = 1;
    if (r != -1) {
        if (!con()) return;
        dfs(v, v, ban);
    } else {
        if (con())
            dfs(v, v, ban);
        fx(to, odd[v]) {
            if (eul.size()) break;
            dsu::unite(v, to);
            if (con()) {
                ban[to] = false;
                dfs(v, v, ban);
                skip = to;
            }
            dsu::rollback();
        }
        if (eul.size() == 0) return;
    }
    assert(eul.size());
    eul.pb(-2);
    fx(to, odd[v]) {
        if (to != skip) {
            eul.pb(to);
            eul.pb(v);
        }
    }
    cout << eul.size() << '\n';
    //cout << eul << '\n';
    fx(x, eul) {
        cout << x + 1 << ' ';
    }
    cout << '\n';
    exit(0);
}

void solve(int v, int l, int r) {
    for (auto[a, b] : dcp[v])
        dsu::unite(a, b);
    if (l + 1 == r) {
        //dbg(l);
        check(l);
    } else {
        int mid = (l + r) / 2;
        solve(2 * v, l, mid);
        solve(2 * v + 1, mid, r);
    }
    fx(x, dcp[v])
        dsu::rollback();
}


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    dsu::init();
    while (m--) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].pb(b);
        g[b].pb(a);
        c[a][b] = c[b][a] = 1;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (!c[i][j]) continue;
            add(1, 0, i, {i, j}, 0, n);
            add(1, i + 1, j, {i, j}, 0, n);
            add(1, j + 1, n, {i, j}, 0, n);
            if (g[j].size() % 2 == 0)
                add(1, i, i + 1, {i, j}, 0, n);
            else 
                odd[i].pb(j);

            if (g[i].size() % 2 == 0)
                add(1, j, j + 1, {i, j}, 0, n);
            else
                odd[j].pb(i);
        }
    }
    solve(1, 0, n);
    cout << "0\n";
}
