Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

NEXTPREV - The next and the previous palindrome

Input

The input consist of unknown number (lower than 100) of tests. Each test is a line with two integers x and y (0<=x<=2*109, length of y is at most 1000).

Output

For each test You should print:

  • the next palindrome of y - if x is even
  • the previous palindrome of y - if x is odd

Example

Input:
10 9029
11 9029 Output:
9119
9009

Note: Leading zeroes don't occur in the input and shouldn't occur in the output.


Added by:Piotr KÄ…kol
Date:2011-06-13
Time limit:1.620s-3.286s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: SCM qobi

hide comments
2011-06-15 19:13:32 HWK
@Piotr: Could you say me where 5251821 fails?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.