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.

bhatabhi554 | 317 |

hardikJain5 | 306 |

CodeBuddy | 293 |

Akkki111 | 233 |

clone | 230 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

mazumderrohit8 | 1176 |

RemoveTLE | 1144 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4605 |

Quandray | 4444 |

Login to report an issue on this page.