Jaypee's girlfriend Parle-G is really annoyed of Jaypee as she didn't like Valentine's gift given by Jaypee to her. As Parle-G love competitive programming too much, so she asks Jaypee a question.
Parle-G gives Jaypee q numbers and asks him to find the largest palindrome <= each number.
Jaypee got stuck in the question. Can u help him out?
Input Format :
First line contains a single integer q denoting the total numbers.
Next q lines contain a single integer n denting the number.
Output Format :
For each n, print a single line containing the largest palindrome <= n.
Constraints :
1<= q <=1000
1<= n <=1000
Greatest palindrome <=4 is 4
Greatest palindrome <=19 is 11
and so on