using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static int[] nm;
    static List<int>[] adj;
    static Deque<int> deq;
    static bool[] th;
    static void Solve()
    {
        nm = Input.ar;
        adj = Enumerable.Repeat(0, nm[0]).Select(_ => new List<int>()).ToArray();
        deq = new Deque<int>(nm[0]);
        while (nm[1]-- > 0)
        {
            var ab = Input.ar;
            ab[0]--;ab[1]--;
            adj[ab[0]].Add(ab[1]);
            adj[ab[1]].Add(ab[0]);
        }
        deq.EnqueueHead(0);
        deq.EnqueueTail(adj[0][0]);
        th = new bool[nm[0]];
        th[0] = true;
        th[adj[0][0]] = true;
        while (!isth()) ;
        var res = new List<int>();
        while (deq.Count != 0)
            res.Add(deq.DequeueHead()+1);
        WriteLine($"{res.Count}\n{string.Join(" ",res)}");
    }
    static bool isth()
    {
        foreach (var ad in adj[deq.PeekHead])
            if(!th[ad])
            { deq.EnqueueHead(ad);th[ad] = true; return false; }
        foreach (var ad in adj[deq.PeekTail])
            if(!th[ad])
            { deq.EnqueueTail(ad);th[ad] = true; return false; }
        return true;
        
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static string[] strs(int n)
        => Enumerable.Repeat(0, n).Select(_ => read).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}
public class Deque<T>
{
    private RingBuffer<T> _buf;
    int _offset = 0, _size;
    public int Count { get; private set; }
    public Deque(int size) { _buf = new RingBuffer<T>(_size = size); }
    public T this[int index]
    {
        get { return _buf[index + _offset]; }
        set { _buf[index + _offset] = value; }
    }
    public void EnqueueHead(T item)
    {
        _buf[--_offset] = item;
        Count++;
    }
    public T DequeueHead()
    {
        if (Count == 0) return default(T);
        Count--;
        return _buf[_offset++];
    }
    public void EnqueueTail(T item)
    {
        _buf[Count++ + _offset] = item;
    }
    public T DequeueTail()
    {
        if (Count == 0) return default(T);
        return _buf[--Count + _offset];
    }
    public T PeekHead { get { return _buf[_offset]; } }
    public T PeekTail { get { return _buf[_offset + Count - 1]; } }
    public T[] ToArray()
    {
        var t = new T[Count];
        for (var i = 0; i < Count; i++)
            t[i] = _buf[i + _offset];
        return t;
    }
}

public class RingBuffer<T>
{
    private T[] _item;
    public int Count { get; private set; }
    public RingBuffer(int size)
    {
        _item = new T[Count = size];
    }
    public T this[int index]
    {
        get { index %= Count; if (index < 0) index += Count; return _item[index]; }
        set {index %= Count;if (index < 0) index += Count; _item[index] = value; }
    }
}


Measured memory_bytes: 33992