#include <stdio.h>
int main ()
{
long long int n ,rev , temp , i , t ,cnt ;
scanf ("%lld",&n) ;
for (i =1 ; i<= n ;i++)
{
rev =0;
cnt =0 ;
scanf ("%lld",&t) ;
while (t != rev)
{
t = t + rev ;
rev =0 ;
temp = t ;
cnt ++ ;
while (temp >0)
{
rev = rev * 10 ;
rev = rev + (temp % 10) ;
temp = temp /10 ;
}
}
printf ("%lld %lld\n",cnt-1 ,rev) ;
}
return 0 ;
}
int main ()
{
long long int n ,rev , temp , i , t ,cnt ;
scanf ("%lld",&n) ;
for (i =1 ; i<= n ;i++)
{
rev =0;
cnt =0 ;
scanf ("%lld",&t) ;
while (t != rev)
{
t = t + rev ;
rev =0 ;
temp = t ;
cnt ++ ;
while (temp >0)
{
rev = rev * 10 ;
rev = rev + (temp % 10) ;
temp = temp /10 ;
}
}
printf ("%lld %lld\n",cnt-1 ,rev) ;
}
return 0 ;
}