import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val r = Array(n) { ArrayList<Int>() }
    for (i in 1..m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() - 1 }
        r[a].add(b)
        r[b].add(a)
    }
    val ans0 = ArrayList<Int>()
    val ans1 = ArrayList<Int>()
    val w = BooleanArray(n)
    w[0] = true

    fun turn(v: Int): Int? {
        return r[v].firstOrNull { !w[it] }
    }
    fun path(ans: MutableList<Int>, vBegin: Int) {
        var v: Int? = vBegin
        while (v != null) {
            ans.add(v)
            w[v] = true
            v = turn(v)
        }
    }

    val v1 = turn(0)
    if (v1 != null) path(ans0, v1)
    val v2 = turn(0)
    if (v2 != null) path(ans1, v2)
    println(ans0.size + ans1.size + 1)
    ans0.reversed().forEach { print("${it + 1} ") }
    print("1 ")
    ans1.forEach { print("${it + 1} ") }
}
