import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
int cases=Integer.parseInt(br.readLine());
StringBuffer sb=new StringBuffer("");
for(int i=0;i<cases;i++){
StringBuilder m=new StringBuilder(br.readLine());
long x,y;
int counter=0;
while(!pali(m.toString())){
x=Long.parseLong(m.toString());
y=Long.parseLong(m.reverse().toString());
m=new StringBuilder(x+y+"");
counter++;
}
sb.append(counter).append(" ").append(m).append("\n");
}
System.out.print(sb);
}
static boolean pali(String s){
for(int i=0,j=s.length()-1;i<s.length()/2;i++,j--){
if(s.charAt(i)!=s.charAt(j)) {
return false;
}
}
return true;
}
}
No comments:
Post a Comment