import Data.Functor -- <$> is not yet in the ideone prelude main = interact f m f=map(f<$>) g=reverse.("":) f s|(f:c:s)<-m fromEnum.g.words$s, (f:c:s)<-init.unwords.g.m(\s->toEnum$if c!!0==s||s==sum(-32:c)then(last$f)else s)$s=init$s