Palindromic queries (bottom up sol)

pls take a look at my code, im not able to identify any logical error.