#include <bits/stdc++.h>   #define fi first   #define se second   #define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)   #define mk make_pair   #define pii pair<int, int>   #define pll pair<ll, ll>   #define pb push_back   #define IT iterator   #define V vector   #define TP template <class o>   #define TPP template <typename t1, typename t2>   #define SZ(a) ((int)a.size())   #define all(a) a.begin(), a.end()   #define rep(i, a, b) for (int i = a; i <= b; i++)   #define REP(i, a, b) for (int i = b; i >= a; i--)   #define FOR(i,n) rep(i,1,n)   #define debug(x) cerr << #x <<   =   << x << endl   using namespace std;   typedef unsigned ui;   typedef long long ll;   typedef unsigned long long ull;   typedef double db;   typedef long double ld;   const int N = 3010, size = 1 << 20, mod = 998244353, inf = 2e9;   const ll INF = 1e15;      // char buf[size],*p1=buf,*p2=buf;   TP void qr(o& x) {       char c = gc;       x = 0;       int f = 1;       while (!isdigit(c)) {           if (c ==  - )               f = -1;           c = gc;       }       while (isdigit(c))           x = x * 10 + c -  0 , c = gc;       x *= f;   }   template<class o,class ... O> void qr(o& x, O& ... y) {qr(x); qr(y...);}   TP void qw(o x) {       if (x / 10)           qw(x / 10);       putchar(x % 10 +  0 );   }   TP void pr1(o x) {       if (x < 0)           x = -x, putchar( - );       qw(x);       putchar(   );   }   template<class o,class ... O> void pr1(o x, O ... y) { pr1(x); pr1(y...);}   TP void pr2(o x) {       if (x < 0)           x = -x, putchar( - );       qw(x);       putchar(  n );   }   template<class o,class ... O> void pr2(o x, O ... y) { pr2(x); pr2(y...);}      // math   ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }   ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }   ll power(ll a, ll b = mod - 2, ll p = mod) {       ll c = 1;       while (b) {           if (b & 1) c = c * a % p;           b /= 2;           a = a * a % p;       }       return c;   }   ll exgcd(ll a,ll b,ll &x,ll &y) {    if(!a) {x=0; y=1; return b;}    ll d=exgcd(b%a,a,y,x); x -= b/a*y;    return d;   }   ll INV(ll n,ll p=mod) {ll x,y; exgcd(n,p,x,y); return (x%p+p)%p;}      TP void cmax(o& x, o y) {       if (x < y)           x = y;   }   TP void cmin(o& x, o y) {       if (x > y)           x = y;   }   TPP void ad(t1& x, t2 y) {       x += y;       if (x >= mod)           x -= mod;   }   TPP void dl(t1& x, t2 y) {       x -= y;       if (x < 0)           x += mod;   }       int n, m, X[N], Y[N];   V<int> e[N], g[N], E, P;   bool v[N];   #define DEBUG      void dfs(int x) {    int i, y;    while(SZ(g[x])) {     i = g[x].back(); g[x].pop_back();     if(v[i]) continue;     y = x ^ X[i] ^ Y[i];     v[i] = 1; dfs(y);    }    P.pb(x);   }      void check(int s, int w = 0) {    FOR(i, n) g[i] = e[i];    FOR(i, m) v[i] = 0;    int cnt = 0;    FOR(i, n) if(i ^ s) cnt += SZ(e[i]) & 1;    if(cnt > 1) return ;    P.clear(); dfs(s);    if(SZ(P) + SZ(E) - 1 - (w > 0) != m) return ;    P.pb(-1);    for(int i: E) if(i ^ w) P.pb(X[i] ^ Y[i] ^ s), P.pb(s);     pr2(SZ(P));    for(int i: P) pr1(i);    exit(0);   }      void solve() {    qr(n, m);    FOR(i, m) qr(X[i], Y[i]);    FOR(s, n) {     FOR(i, n) e[i].clear();     P.clear(); E.clear();     FOR(i, m) {      int x = X[i], y = Y[i];      if(x == s || y == s) continue;      e[x].pb(i); e[y].pb(i);     }     FOR(i, m) {      int x = X[i], y = Y[i];      if(x == s || y == s) {       int v = s ^ x ^ y;       if(SZ(e[v]) & 1) e[s].pb(i), e[v].pb(i);       else E.pb(i);      }     }     check(s);     for(int i: E) {      e[X[i]].pb(i); e[Y[i]].pb(i);      check(s, i);      e[X[i]].pop_back(); e[Y[i]].pop_back();     }    }    puts( 0 );   }      int main() {       int T = 1;   //    qr(T);       while (T--)           solve();       return 0;   }