Jaypee and Parle-G

4

1 votes
Implementation, Brute Force, Easy
Problem

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

 

 


 

Sample Input
5
4
19
59
198
976
Sample Output
4
11
55
191
969
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Greatest palindrome <=4 is 4
Greatest palindrome <=19 is 11
and so on

Editor Image

?