
import Data.Char (toLower)

rotations xs = take (l - 1) $ map (take l) $ tail $ iterate tail c
    where l = length xs
          c = cycle xs

lyndon s = all (> s) (rotations s)

main = interact $ unlines . filter (lyndon . map toLower) . lines

