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.

jhasaurabh312 | 138 |

Aaaaarohiiii | 136 |

Harsha_kunchala | 128 |

tushki | 124 |

RajaRajput | 117 |

ARUN_PUNDIR | 617 |

manishgupta8497 | 607 |

Abhimanyu_kumar | 559 |

KhyatiSoneji | 501 |

Aman___Jain | 496 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.