Choosing a Palindromic Sequence

SPOJ - PALSEC