1.

/*
* ACM Contest training
* Problem: 10018 - Reverse and Add
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=12&problem=959
*
* @author Christoph Goettschkes
* @version 1.0, 01/06/2011
*
* Method : Ad-Hov
* Status : Accepted
* Runtime: 0.016
*/

#include <stdio.h>

unsigned long long reverse(unsigned long long number) {
long long tmp = 0;
while (number > 0) {
tmp = tmp * 10 + number % 10;
number /= 10;
}
return tmp;
}

int main() {
long long n;
long long counter;
long long rev;
long long tc;
scanf("%lld", &tc);
while (tc--) {
scanf("%lld", &n);
rev = reverse(n);
counter = 1;
if (n == rev) {
printf("%d %lld\n", 0, n);
continue;
}
for (counter = 1; counter <= 1000; counter++) {
n += rev;
rev = reverse(n);
if (n == rev)
break;
}
printf("%lld %lld\n", counter, n);

}
return 0;
}