#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, long long);
long long reversa(long long);
int scanf(char *, ...);
int main() {
  long long int a, b;
  int i, j, t;
  while (scanf("%d", &t) == 1) {
    for (i = 1; i <= t; i++) {
      scanf("%lld", &a);
      j = 0;
      while (1) {
        b = reversa(a);
        if (a == b)
          break;
        else {
          a = a + b;
          j++;
        }
      }
      printf("%d %lld\n", j, b);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11e6 <main+0xb6>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11e1 <main+0xb1>
lea    0xe8f(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <reversa@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11a6 <main+0x76>
jmp    11c0 <main+0x90>
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1186 <main+0x56>
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1161 <main+0x31>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    120c <main+0xdc>
lea    0xc(%rsp),%r15
lea    0xe9d(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xe96(%rip),%rbx
jmp    1196 <main+0x66>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe79(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    120c <main+0xdc>
cmpl   $0x0,0xc(%rsp)
jle    1180 <main+0x50>
mov    $0x1,%r14d
jmp    11cb <main+0x9b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
lea    0x1(%r14),%eax
cmp    0xc(%rsp),%r14d
mov    %eax,%r14d
jge    1180 <main+0x50>
xor    %ebp,%ebp
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%rdi
call   1030 <reversa@plt>
mov    0x10(%rsp),%rdi
cmp    %rax,%rdi
je     11b0 <main+0x80>
xor    %ebp,%ebp
add    %rax,%rdi
mov    %rdi,0x10(%rsp)
add    $0x1,%ebp
call   1030 <reversa@plt>
mov    0x10(%rsp),%rdi
cmp    %rax,%rdi
jne    11f0 <main+0xc0>
jmp    11b0 <main+0x80>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [9 x i8] c"%d %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
br label %7
7: ; preds = %38, %0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %39
10: ; preds = %7
store i32 1, i32* %4
br label %11
11: ; preds = %35, %10
%12 = load i32, i32* %4
%13 = load i32, i32* %6
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %38
15: ; preds = %11
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
store i32 0, i32* %5
br label %17
17: ; preds = %15, %30
%18 = load i64, i64* %2
%19 = call i64 @reversa(i64 %18)
store i64 %19, i64* %3
%20 = load i64, i64* %2
%21 = load i64, i64* %3
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %17
br label %31
24: ; preds = %17
%25 = load i64, i64* %2
%26 = load i64, i64* %3
%27 = add nsw i64 %25, %26
store i64 %27, i64* %2
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %30
30: ; preds = %24
br label %17
31: ; preds = %23
%32 = load i32, i32* %5
%33 = load i64, i64* %3
%34 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %32, i64 %33)
br label %35
35: ; preds = %31
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %11
38: ; preds = %11
br label %7
39: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [9 x i8] c"%d %lld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i32
%3 = bitcast i64* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %10, label %36
7: ; preds = %29, %10
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %36
10: ; preds = %0, %7
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 1
br i1 %12, label %7, label %13
13: ; preds = %10, %29
%14 = phi i32 [ %33, %29 ], [ 1, %10 ]
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%16 = load i64, i64* %1
%17 = call i64 @reversa(i64 %16)
%18 = load i64, i64* %1
%19 = icmp eq i64 %18, %17
br i1 %19, label %29, label %20
20: ; preds = %13, %20
%21 = phi i64 [ %27, %20 ], [ %18, %13 ]
%22 = phi i64 [ %26, %20 ], [ %17, %13 ]
%23 = phi i32 [ %25, %20 ], [ 0, %13 ]
%24 = add nsw i64 %21, %22
store i64 %24, i64* %1
%25 = add nuw nsw i32 %23, 1
%26 = call i64 @reversa(i64 %24)
%27 = load i64, i64* %1
%28 = icmp eq i64 %27, %26
br i1 %28, label %29, label %20
29: ; preds = %20, %13
%30 = phi i32 [ 0, %13 ], [ %25, %20 ]
%31 = phi i64 [ %17, %13 ], [ %26, %20 ]
%32 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %30, i64 %31)
%33 = add nuw nsw i32 %14, 1
%34 = load i32, i32* %2
%35 = icmp slt i32 %14, %34
br i1 %35, label %13, label %7
36: ; preds = %7, %0
ret i32 0
}