{-# OPTIONS_GHC -O #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}

import Data.List
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as B
import qualified Data.Map.Strict as M

dfs grp ps n
    | length ps == 3 = Just (n:ps)
    | True = join$find isJust$fmap (dfs grp (n:ps)) [n|n<-ns, not$elem n ps]
        where ns=M.findWithDefault [] n grp

main=do
    [n,m]<-map read.words<$>getLine
    grp<-foldM insmap M.empty [1..m]
    let Just x =  dfs grp [] 1
    print 4
    putStrLn $ drop 1 $ foldl' (\s i->s ++ " " ++ show i) "" x

insmap :: M.Map Int [Int] -> a -> IO (M.Map Int [Int])
insmap g _ = do
    [a,b] <- unfoldr (B.readInt.B.dropWhile (==' '))<$>B.getLine
    let g' = M.insert a (b:(M.findWithDefault [] a g)) g
    return $ M.insert b (a:(M.findWithDefault [] b g')) g'
