#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 *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int m[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  int t;
  scanf("%d", &t);
  while (t--) {
    long long int a, b, sum = 0;
    scanf("%lld%lld", &a, &b);
    a += b;
    while (a > 0) {
      sum += m[a % 10];
      a /= 10;
    }
    printf("%lld\n", sum);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xecd(%rip),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x34(%rbp)
cmp    $0x0,%eax
je     11f6 <main+0xc6>
movq   $0x0,-0x50(%rbp)
lea    0xea2(%rip),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x48(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jle    11e1 <main+0xb1>
mov    -0x40(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
movslq -0x30(%rbp,%rdx,4),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x40(%rbp)
jmp    11a4 <main+0x74>
mov    -0x50(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
jmp    1166 <main+0x36>
mov    -0x4(%rbp),%eax
add    $0x50,%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    0xef3(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    1159 <main+0x39>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xecb(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe8f(%rip),%rbx
movabs $0xcccccccccccccccd,%rbp
cc cc cc
lea    0xeb2(%rip),%r13
jmp    11a6 <main+0x86>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %esi,%esi
mov    %rdx,0x8(%rsp)
mov    %r13,%rdi
call   1030 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     1148 <main+0x28>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%rdx
add    0x10(%rsp),%rdx
jle    1190 <main+0x70>
xor    %esi,%esi
mov    %rdx,%rcx
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rax
mul    %rbp
shr    $0x3,%rdx
lea    (%rdx,%rdx,1),%rax
lea    (%rax,%rax,4),%rax
mov    %rcx,%rdi
sub    %rax,%rdi
movslq (%rbx,%rdi,4),%rax
add    %rax,%rsi
cmp    $0x9,%rcx
mov    %rdx,%rcx
ja     11d0 <main+0xb0>
jmp    1192 <main+0x72>

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

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