Trisha is very good at maths. One day she was discussing palindromes. Her teacher asks Trisha to explain palindromes to the class, after doing so, her teacher asks her to find the smallest palindrome greater than 10, Trisha in no time answers the question answer: 11, moving forward her teacher starts asking her the same question for large values. As Trisha does not want to lose her reputation in the class, she asks you for help.

**Input: **

The first line of the input contains an integer **T** denoting the number of test cases. The description of each test case is as follows. Each test case contains a single line with one integer ' X ' for which you have to find the smallest palindrome greater than the input number (X).

**Output: **For each X, output the smallest palindrome greater than X.

**Constraints: **

1 < = T < = 10000

1 < = X < = 10000

**Example:**

**Input:**

4

23

189

10009

33

**Output:**

33

191

10101

44

**Explanation: **For the first test case 23 the smallest number which is a palindrome and greater than 23 is 33.

Author: diksha1812

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Vagesh Verma | 98 |

UrGuru | 98 |

chaolinyu | 84 |

prernaus24 | 83 |

devendrachoudhary5485 | 74 |

abducodes | 624 |

harshtyagi36 | 298 |

highway_to_hell | 252 |

rajeswarii | 248 |

arpit_anshuman | 240 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.