1. 
/**
 * FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
 * Problem: 10018 - Reverse and Add
 * Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=959
 *
 * @author Evgeni Pavlidis
 * @version 1.0, 06/02/2010
 *
 * Method : Ad hoc
 * Status : Accepted
 * Runtime: 0.356
 */

import java.io.*;
import java.util.*;

class Main {

    private static boolean isPalindrome(String s)
    {
        for(int i = 0; i < s.length(); i++)
            if(s.charAt(i) != s.charAt(s.length()-i-1))
                return false;
        return true;
    }

    public static void main(String...args) throws Exception
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        long n, counter;
        int testCases = Integer.parseInt(reader.readLine());

        for(int c = 0; c < testCases; c++)
        {
            n = Long.parseLong(reader.readLine());
            counter = 0;

            while(!isPalindrome("" + n))
            {
                counter++;
                n = n + Long.parseLong(new StringBuffer(""+n).reverse().toString());
            }

            System.out.println(counter + " " + n);
        }
    }
}