#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <deque>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pii pair<pi,int>
#define sqr(x) ((x)*(x))
#define itn int
#define inr int 
#define retunr return
#define FOR for(int i=0;i<n;i++)for(int j=0;j<m;j++)
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
vector<int>asd[100005];
bool used[10005];
vector<int>pa;
vector<int>pb;
void dfs(int x){
	used[x]=true;
	pa.pb(x);
	for(int nxt:asd[x]){
		if(used[nxt]==false){dfs(nxt);retunr;}}}
		
int main()
{
	cin.sync_with_stdio(false) ;
	int n,m;
	cin>>n>>m;
	for(inr i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		asd[a].push_back(b);
		asd[b].push_back(a);}
	dfs(1);
	swap(pa,pb);
	dfs(1);
	cout<<pa.size() +pb.size()-1<<endl;
	for(int i=(int)pb.size()-1;i>=1;i--)cout<<pb[i];
	for(int t:pa)cout<<t;
	cout<<endl;

    

//system("pause");
    return 0;
}
