import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
class Main {
int t
= Integer.
parseInt(br.
readLine()); while (t-- > 0) {
s = s.trim();
if(s.charAt(0) == '0') {
while(s.charAt(0) == '0')
s = s.substring(1);
}
if (all9(s)) {
continue;
}
int i = 0, j = s.length() - 1;
int mid = (i + j) / 2;
String f
= s.
substring(0, mid
+ 1); String rev
= rev
((s.
length() % 2 == 0) ? s.
substring(0, mid
+ 1) : s.
substring(0, mid
));
while (ans.compareTo(s) <= 0) {
ans = big(ans);
}
}
}
private static boolean all9
(String s
) { // TODO Auto-generated method stub
int i = 0;
while (i < s.length()) {
if (s.charAt(i) != '9')
return false;
i++;
}
return true;
}
int mid = ans.length() / 2;
if (ans.length() % 2 == 0) {
f = ans.substring(0, mid);
} else {
f = ans.substring(0, mid + 1);
}
s = s + b;
String rev
= rev
((ans.
length() % 2 == 0) ? s
: s.
substring(0, mid
)); ans = s + rev;
return ans;
}
// TODO Auto-generated method stub
return new StringBuilder(s).reverse().toString();
}
}
aW1wb3J0IGphdmEuaW8uQnVmZmVyZWRSZWFkZXI7CmltcG9ydCBqYXZhLmlvLklPRXhjZXB0aW9uOwppbXBvcnQgamF2YS5pby5JbnB1dFN0cmVhbVJlYWRlcjsKaW1wb3J0IGphdmEubWF0aC5CaWdJbnRlZ2VyOwoKY2xhc3MgTWFpbiB7CgoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgdGhyb3dzIE51bWJlckZvcm1hdEV4Y2VwdGlvbiwgSU9FeGNlcHRpb24gewoJCSBCdWZmZXJlZFJlYWRlciBiciA9IG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgSW5wdXRTdHJlYW1SZWFkZXIoU3lzdGVtLmluKSk7CgkJaW50IHQgPSBJbnRlZ2VyLnBhcnNlSW50KGJyLnJlYWRMaW5lKCkpOwoJCXdoaWxlICh0LS0gPiAwKSB7CgkJCVN0cmluZyBzID0gYnIucmVhZEx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697829238862994263278849942632926438725
857751275744476297149515661
699
5119783738665448121162642286
4177118624313412937235746451