#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn dfs(
    start: usize,
    i: usize,
    edge: &[Vec<usize>],
    path: &mut Vec<usize>,
    visited: &mut Vec<bool>,
) -> bool {
    visited[i] = true;
    path.push(i);

    if edge[i].iter().all(|&x| visited[x]) && edge[start].iter().all(|&x| visited[x]) {
        return true;
    }

    for &to in &edge[i] {
        if !visited[to] {
            if dfs(start, to, edge, path, visited) {
                return true;
            }
        }
    }
    visited[i] = false;
    path.pop();
    false
}

fn main() {
    let (n, m): (usize, usize) = util::get2();
    let mut edges = vec![Vec::new(); n];

    for _ in 0..m {
        let (a, b): (usize, usize) = util::get2();
        edges[a - 1].push(b - 1);
        edges[b - 1].push(a - 1);
    }

    let mut path = Vec::new();
    let mut visited = vec![false; n];

    let start = (0..n).min_by_key(|&i| edges[i].len()).unwrap();
    assert!(dfs(start, start, &edges, &mut path, &mut visited));

    println!("{}", path.len());
    println!(
        "{}",
        path.iter()
            .map(|&x| (x + 1).to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}


Measured memory_bytes: 24956