#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char a[1000002];
int test,i,flag,check,l,m,k;
while(test--)
{
flag=1;
// baseof(length / 2) in integer.
k=l>>1;
//printf("k=%d\n",k);
check=0;
for(i=0;i<l;i++)
{
if(a[i]!='9')
{
flag=0;
//printf("a\n");
break;
}
}
//handaling case when 9, 99, 999 is given.(only 9s)
if(flag==1)
{
a[0]='1';
for(i=1;i<l;i++)
a[i]='0';
a[l]='1';
a[l+1]='\0';
check=1; //to check palindrom or not number
}
flag=0;
if(check!=1)
{
for(i=0;i<k;i++)
{
if(a[i]<a[l-1-i]){
flag=-1;
//printf("flag=-1\n");
}
else if(a[i]>a[l-1-i]){
//printf("flag=1\n");
flag=1;}
a[l-1-i]=a[i];
}
if(!(l&1))
m=k-1;
else m=k;
if(flag==0||flag==-1)
{
i=0;
while(a[m-i]=='9')
{
a[m-i]='0';
a[l-1-m+i]='0';
i++;
}
a[m-i]++;
a[l-1-m+i]=a[m-i];
}
}
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RyaW5nLmg+CiNpbmNsdWRlPHN0ZGxpYi5oPgppbnQgbWFpbigpCnsKICAgIGNoYXIgYVsxMDAwMDAyXTsKICAgIGludCB0ZXN0LGksZmxhZyxjaGVjayxsLG0sazsKICAgIHNjYW5mKCIlZFxuIiwmdGVzdCk7CiAgICB3aGlsZSh0ZXN0LS0pCiAgICB7CiAgICAgICAgZmxhZz0xOwogICAgICAgIGdldHMoYSk7CiAgICAgICAgbD1zdHJsZW4oYSk7CiAgICAgICAgLy8gYmFzZW9mKGxlbmd0aCAvIDIpIGluIGludGVnZXIuCiAgICAgICAgaz1sPj4xOyAKICAgICAgICAvL3ByaW50Zigiaz0lZFxuIixrKTsKICAgICAgICBjaGVjaz0wOwogICAgICAgIGZvcihpPTA7aTxsO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKGFbaV0hPSc5JykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZmxhZz0wOwogICAgICAgICAgICAgICAgLy9wcmludGYoImFcbiIpOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgLy9oYW5kYWxpbmcgY2FzZSB3aGVuIDksIDk5LCA5OTkgaXMgZ2l2ZW4uKG9ubHkgOXMpCiAgICAgICAgaWYoZmxhZz09MSkKICAgICAgICB7CiAgICAgICAgICAgIGFbMF09JzEnOwogICAgICAgICAgICBmb3IoaT0xO2k8bDtpKyspCiAgICAgICAgICAgIGFbaV09JzAnOwogICAgICAgICAgICBhW2xdPScxJzsKICAgICAgICAgICAgYVtsKzFdPSdcMCc7CiAgICAgICAgICAgIGNoZWNrPTE7IC8vdG8gY2hlY2sgcGFsaW5kcm9tIG9yIG5vdCBudW1iZXIKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgZmxhZz0wOwogICAgICAgIGlmKGNoZWNrIT0xKQogICAgICAgIHsKICAgICAgICAgICAgZm9yKGk9MDtpPGs7aSsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZihhW2ldPGFbbC0xLWldKXsKICAgICAgICAgICAgICAgIGZsYWc9LTE7CiAgICAgICAgICAgICAgICAvL3ByaW50ZigiZmxhZz0tMVxuIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlIGlmKGFbaV0+YVtsLTEtaV0pewogICAgICAgICAgICAgICAgLy9wcmludGYoImZsYWc9MVxuIik7CiAgICAgICAgICAgICAgICBmbGFnPTE7fQogICAgICAgICAgICAgICAgYVtsLTEtaV09YVtpXTsKICAgICAgICAgICAgfQogCiAgICAgICAgICAgIGlmKCEobCYxKSkKICAgICAgICAgICAgbT1rLTE7CiAgICAgICAgICAgIGVsc2UgbT1rOwogICAgICAgICAgICBpZihmbGFnPT0wfHxmbGFnPT0tMSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaT0wOwogICAgICAgICAgICAgICAgd2hpbGUoYVttLWldPT0nOScpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgYVttLWldPScwJzsKICAgICAgICAgICAgICAgICAgICBhW2wtMS1tK2ldPScwJzsKICAgICAgICAgICAgICAgICAgICBpKys7CiAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgIGFbbS1pXSsrOwogICAgICAgICAgICAgICAgYVtsLTEtbStpXT1hW20taV07CiAgICAgICAgfQogICAgfQogICAgcHJpbnRmKCIlc1xuIixhKTsKICAgIH0KICAgIHJldHVybiAwOwp9