the next palindrome spoj solution