
import Data.Char (toLower)

rotations xs = map (take l . flip drop c) [1..l-1]
    where l = length xs
          c = cycle xs

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

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

