#include <bits/stdc++.h>
#include
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long int t,k,pal=0;
cin >> t;
string num,num1;
while(t–){
cin >> k;
while(pal != 1){
k++;
num = to_string(k);
num1 = num;
reverse(num1.begin(),num1.end());
if(num == num1){
cout<<num<<"\n";
pal=1;
}
}
pal=0;
}
}