#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxn = 3000;
int n, m;
int a[mxn], b[mxn], d[mxn], f[mxn], vis[mxn];
vector<int> v;
vector<int> g[mxn];

void dfs(int c){
	for(int i; f[c] < g[c].size(); f[c]++) if(!vis[i = g[c][f[c]]]){
		vis[i] = 1;
		dfs(c ^ a[i] ^ b[i]);
		v.push_back(i);
	}
}

void sol(int c){
	for(int i = 0; i < m; i++) if(vis[i]) d[a[i]]--, d[b[i]]--;
	int x = -2 * (d[c] & 1);
	for(int i = 0; i < n; i++) x += d[i] & 1;
	for(int i = 0; i < m; i++) if(vis[i]) d[a[i]]++, d[b[i]]++;
	if(x) return;
	
	v.clear();
	memset(f, 0, sizeof(f));
	dfs(c);
	
	for(int i : v) vis[i] = 0;
	if(v.size() + count(vis, vis + m, 1) < m) return;
	
	v.push_back(c);
	for(int i = v.size() - 2; ~i; i--) v[i] = v[i + 1] ^ a[v[i]] ^ b[v[i]];
	
	if(v.size() != m + 1) v.push_back(-2);
	for(int i : g[c]) if(vis[i]){
		v.push_back(c ^ a[i] ^ b[i]);
		v.push_back(c);
	}
	
	cout << v.size() << endl;
	cout << (v[0] + 1);
	for(int i = 1; i < v.size(); i++) cout << " " << (v[i] + 1);
	cout << endl;
	
	exit(0);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		d[--a[i]]++, d[--b[i]]++;
		g[a[i]].push_back(i);
		g[b[i]].push_back(i);
	}
	
	for(int i = 0; i < n; i++){
		for(int j : g[i]) if(d[i ^ a[j] ^ b[j]] & 1) vis[j] = 1;
		sol(i);
		for(int j : g[i]) vis[j] ^= 1, sol(i), vis[j] ^= 1;
		for(int j : g[i]) vis[j] = 0;
	}
	
	cout << 0 << endl;
	
	return 0;
}