Read problems statements in [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well.

Chef's son Chefu found some matches in the kitchen and he immediately starting playing with them.

The first thing Chefu wanted to do was to calculate the result of his homework — the sum of $A$ and $B$, and write it using matches. Help Chefu and tell him the number of matches needed to write the result.

Digits are formed using matches in the following way:

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains two space-separated integers $A$ and $B$.

------  Output ------
For each test case, print a single line containing one integer — the number of matches needed to write the result ($A+B$).

------  Constraints ------
$1 ≤ T ≤ 1,000$
$1 ≤ A, B ≤ 10^{6}$

----- Sample Input 1 ------ 
3

123 234

10101 1010

4 4
----- Sample Output 1 ------ 
13

10

7
----- explanation 1 ------ 
Example case 1: The result is $357$. We need $5$ matches to write the digit $3$, $5$ matches to write the digit $5$ and $3$ matches to write the digit $7$.

Example case 2: The result is $11111$. We need $2$ matches to write each digit $1$, which is $2 \cdot 5 = 10$ matches in total.

Difficulty: EASY

Solutions:
T = int(input())
for x in range(T):
	data = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
	(A, B) = map(int, input().split())
	total = A + B
	lst = [int(x) for x in str(total)]
	sec = [data[t] for t in lst]
	fin = sum(sec)
	print(fin)


z = int(input(''))
for i in range(z):
	(a, b) = map(int, input().split())
	l = a + b
	lo = 0
	c = str(l)
	k = len(c)
	for i in range(k):
		d = c[i]
		if d == '1':
			lo = lo + 2
		elif d == '2' or d == '3' or d == '5':
			lo = lo + 5
		elif d == '4':
			lo = lo + 4
		elif d == '6' or d == '9' or d == '0':
			lo = lo + 6
		elif d == '7':
			lo = lo + 3
		elif d == '8':
			lo = lo + 7
	print(lo)


for i in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	z = a + b
	sum = 0
	dicti = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
	for i in str(z):
		t = dicti[int(i)]
		sum += t
	print(sum)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	dic = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	ans = a + b
	s = str(ans)
	res = 0
	for num in s:
		res += dic[num]
	print(res)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	sum1 = a + b
	temp = 0
	while sum1 > 0:
		k = sum1 % 10
		if k == 0 or k == 6 or k == 9:
			temp = temp + 6
		elif k == 2 or k == 3 or k == 5:
			temp = temp + 5
		elif k == 1:
			temp = temp + 2
		elif k == 4:
			temp = temp + 4
		elif k == 7:
			temp = temp + 3
		else:
			temp = temp + 7
		sum1 = sum1 // 10
	print(temp)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	dic = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	c = a + b
	c = str(c)
	an = 0
	for i in c:
		an += dic[i]
	print(an)


t = int(input())
for i in range(0, t):
	match = list(map(int, input().split()))
	temp = match[0] + match[1]
	dictu = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	digit = list(str(temp))
	sums = 0
	for j in digit:
		sums = sums + dictu[j]
	print(sums)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	s = str(a + b)
	a = 0
	for i in s:
		if i == '0':
			a += 6
		elif i == '1':
			a += 2
		elif i == '2':
			a += 5
		elif i == '3':
			a += 5
		elif i == '4':
			a += 4
		elif i == '5':
			a += 5
		elif i == '6':
			a += 6
		elif i == '7':
			a += 3
		elif i == '8':
			a += 7
		elif i == '9':
			a += 6
	print(a)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	A = x + y
	dict = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	A = str(A)
	count = 0
	for i in A:
		count += dict[i]
	print(count)


l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for i in range(int(input())):
	(a, b) = map(int, input().split())
	(sum, total_matchSticks) = (a + b, 0)
	for j in str(sum):
		total_matchSticks = total_matchSticks + l[int(j)]
	print(total_matchSticks)


t = int(input())
l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for i in range(t):
	sum = 0
	(a, b) = map(int, input().split())
	c = a + b
	c = str(c)
	for n in c:
		sum = sum + l[int(n)]
	print(sum)


d = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	s = str(a + b)
	c = 0
	for j in s:
		c += d[j]
	print(c)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	d = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
	s = a + b
	m = 0
	while s:
		r = s % 10
		m = m + d[r]
		s = s // 10
	print(m)


T = int(input())
for i in range(T):
	(A, B) = map(int, input().split())
	d = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	s = A + B
	s = str(s)
	count = 0
	for i in s:
		count += d[i]
	print(count)


a = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
t = int(input())
while t > 0:
	(d, b) = map(int, input().split())
	c = d + b
	sum = 0
	while c != 0:
		sum += a[c % 10]
		c = c // 10
	print(sum)
	t -= 1


for i in range(int(input())):
	d = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
	(x, y) = map(int, input().split())
	su = x + y
	su = str(su)
	c = 0
	for i in su:
		c += d[int(i)]
	print(c)


dict = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	n = a + b
	c = 0
	while n:
		digit = n % 10
		n //= 10
		c = c + dict[digit]
	print(c)


vp = int(input())
for i in range(vp):
	(t, z) = map(int, input().split())
	c = 0
	r = 0
	n = t + z
	n = str(n)
	for k in n:
		if k == '0':
			r = 6
			c = c + r
		if k == '1':
			r = 2
			c = c + r
		if k == '2':
			r = 5
			c = c + r
		if k == '3':
			r = 5
			c = c + r
		if k == '4':
			r = 4
			c = c + r
		if k == '5':
			r = 5
			c = c + r
		if k == '6':
			r = 6
			c = c + r
		if k == '7':
			r = 3
			c = c + r
		if k == '8':
			r = 7
			c = c + r
		if k == '9':
			r = 6
			c = c + r
	print(c)


n = int(input())
y = [[0, 6], [1, 2], [2, 5], [3, 5], [4, 4], [5, 5], [6, 6], [7, 3], [8, 7], [9, 6]]
for i in range(n):
	count = 0
	(a, b) = map(int, input().split())
	res = a + b
	r = str(res)
	for j in range(len(r)):
		p = int(r[j])
		count += y[p][1]
	print(count)


LIST_OF_MATCH_STICK = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for _ in range(int(input())):
	(FIRST_NUMBER, SECOND_NUMBER) = list(map(int, input().split()))
	SUM_OF_NUMBER = FIRST_NUMBER + SECOND_NUMBER
	DIGITS_NUMBER = 0
	COUNT_OF_SUM = 0
	while SUM_OF_NUMBER > 0:
		DIGITS_NUMBER = SUM_OF_NUMBER % 10
		COUNT_OF_SUM += LIST_OF_MATCH_STICK[DIGITS_NUMBER]
		SUM_OF_NUMBER //= 10
	print(COUNT_OF_SUM)


match = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
match = {int(k): int(v) for (k, v) in match.items()}
for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = a + b
	res = [int(x) for (a, x) in enumerate(str(c))]
	r = 0
	for i in res:
		r += match[i]
	print(r)


dict1 = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	m = a + b
	s = 0
	while m != 0:
		rem = m % 10
		s += dict1[rem]
		m = m // 10
	print(s)


matches = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	sum = a + b
	total_matches = 0
	for digit in str(sum):
		total_matches += matches[int(digit)]
	print(total_matches)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	dict = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
	x = list(str(n + k))
	count = 0
	for i in x:
		count += dict.get(int(i))
	print(count)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	n = a + b
	count = 0
	while n > 0:
		rem = n % 10
		if rem == 0 or rem == 9 or rem == 6:
			count += 6
		elif rem == 1:
			count += 2
		elif rem == 2 or rem == 3 or rem == 5:
			count += 5
		elif rem == 7:
			count += 3
		elif rem == 4:
			count += 4
		else:
			count += 7
		n = n // 10
	print(count)


def count_matches(num):
	matches_dict = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	total_matches = 0
	for digit in str(num):
		total_matches += matches_dict[digit]
	return total_matches
T = int(input())
for i in range(T):
	(A, B) = map(int, input().split())
	result = A + B
	matches_needed = count_matches(result)
	print(matches_needed)


n = int(input())
for i in range(n):
	x = input()
	x = list(map(int, x.split()))
	m = x[0] + x[1]
	m = str(m)
	k = 0
	for j in m:
		if int(j) == 0:
			c = 6
		if int(j) == 1:
			c = 2
		if int(j) == 2:
			c = 5
		if int(j) == 3:
			c = 5
		if int(j) == 4:
			c = 4
		if int(j) == 5:
			c = 5
		if int(j) == 6:
			c = 6
		if int(j) == 7:
			c = 3
		if int(j) == 8:
			c = 7
		if int(j) == 9:
			c = 6
		k = k + c
	print(k)


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	dic = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	C = A + B
	D = str(C)
	count = 0
	for i in D:
		count += dic[i]
	print(count)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	total = x + y
	digit = 0
	while total > 0:
		a = total % 10
		if a == 0:
			digit += 6
		elif a == 1:
			digit += 2
		elif a == 2:
			digit += 5
		elif a == 3:
			digit += 5
		elif a == 4:
			digit += 4
		elif a == 5:
			digit += 5
		elif a == 6:
			digit += 6
		elif a == 7:
			digit += 3
		elif a == 8:
			digit += 7
		elif a == 9:
			digit += 6
		total = total // 10
	print(digit)


k = int(input())
for i in range(k):
	(m, n) = map(int, input().split())
	o = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	c = m + n
	c = str(c)
	oh = 0
	for i in c:
		oh += o[i]
	print(oh)


t = int(input())
for i in range(0, t):
	(a, b) = map(int, input().split(' '))
	m = a + b
	sum = 0
	while m > 0:
		r = m % 10
		if r == 0 or r == 6 or r == 9:
			sum += 6
		elif r == 2 or r == 3 or r == 5:
			sum += 5
		elif r == 1:
			sum += 2
		elif r == 4:
			sum += 4
		elif r == 7:
			sum += 3
		else:
			sum += 7
		m = m // 10
	print(sum)


t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	sum = A + B

	def matchCount(*args):
		count = 0
		for i in args:
			if i == 0:
				count += 6
			elif i == 1:
				count += 2
			elif i == 2 or i == 3 or i == 5:
				count += 5
			elif i == 4:
				count += 4
			elif i == 6 or i == 9:
				count += 6
			elif i == 7:
				count += 3
			else:
				count += 7
		return count
	list1 = list(map(int, str(sum)))
	print(matchCount(*list1))


test = int(input())
for i in range(test):
	(a, b) = map(int, input().split())
	d = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
	r = a + b
	c = 0
	while r > 0:
		n = r % 10
		c = c + d.get(n)
		r = r // 10
	print(c)


n = int(input())
l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for j in range(n):
	(a, b) = map(int, input().split())
	c = a + b
	m = 0
	s = 0
	while c > 0:
		m = c % 10
		for i in range(len(l)):
			if m == i:
				s += l[i]
				break
		c = c // 10
	print(s)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	r = a + b
	l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
	str_r = str(r)
	count = 0
	for i in str_r:
		num = int(i)
		stick = l[num]
		count = count + stick
	print(count)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	z = x + y
	s = str(z)
	c = 0
	for j in s:
		if j == '0' or j == '6' or j == '9':
			c = c + 6
		elif j == '2' or j == '3' or j == '5':
			c = c + 5
		elif j == '1':
			c = c + 2
		elif j == '4':
			c = c + 4
		elif j == '7':
			c = c + 3
		else:
			j == '8'
			c = c + 7
	print(c)


dic = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = a + b
	t = 0
	while c:
		d = c % 10
		c = c // 10
		t = t + dic[d]
	print(t)


def matches_needed(number):
	sticks = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
	matches = 0
	while number > 0:
		matches += sticks[number % 10]
		number //= 10
	return matches
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	total_matches = matches_needed(a + b)
	print(total_matches)


for i in range(int(input())):
	(m, n) = map(int, input().split())
	t = str(m + n)
	summ = 0
	l = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	p = 0
	for j in range(len(t)):
		summ += l[t[p]]
		p += 1
	print(summ)


matches = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
T = int(input())
while T != 0:
	(A, B) = map(int, input().split())
	S = A + B
	cnt = 0
	while S != 0:
		d = S % 10
		if d in matches:
			cnt += matches[d]
		S //= 10
	print(cnt)
	T -= 1


n = int(input())
for i in range(1, n + 1):
	(a, b) = [int(i) for i in input().split()]
	c = a + b
	v = []
	dict1 = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	c = str(c)
	res = 0
	for i in c:
		res += dict1[i]
	print(res)


for i in range(int(input())):
	(s1, s2) = map(int, input().split())
	d = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	ad = str(s1 + s2)
	c = 0
	for j in ad:
		c += d[j]
	print(c)


for i in range(int(input())):
	dic = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	(a, b) = map(int, input().split())
	add = str(a + b)
	ans = 0
	for j in add:
		ans += dic[j]
	print(ans)


dic = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	a += b
	a = str(a)
	res = 0
	for x in a:
		res += dic[int(x)]
	print(res)


t = int(input())
for i in range(t):
	l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
	(n, m) = map(int, input().split())
	s = n + m
	p = 0
	while s > 0:
		r = s % 10
		s = s // 10
		p = p + l[r]
	print(p)


matchstick_dict = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
cases = int(input())
for i in range(cases):
	C = 0
	(A, B) = map(int, input().split(' '))
	C = str(A + B)
	num = list(C)
	num = [matchstick_dict[item] for item in num]
	print(sum(num))


t = int(input())
dic = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
for i in range(t):
	(a, b) = map(int, input().split())
	c = a + b
	count = 0
	while c != 0:
		rem = c % 10
		count = count + dic[rem]
		c = c // 10
	print(count)


T = int(input())
for i in range(T):
	ab = list(map(int, input().split()))
	total = ab[0] + ab[1]
	matches = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
	if total < 10:
		print(matches[total])
	else:
		total_matches = 0
		while True:
			lastnumber = total % 10
			total_matches += matches[lastnumber]
			total //= 10
			if total < 10:
				total_matches += matches[total]
				break
		print(total_matches)


T = int(input())
for i in range(T):
	ab = list(map(int, input().split()))
	sum_of_ab = ab[0] + ab[1]
	matches = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
	if sum_of_ab < 10:
		print(matches[sum_of_ab])
	else:
		counter = 0
		while True:
			last_digit = sum_of_ab % 10
			counter += matches[last_digit]
			sum_of_ab //= 10
			if sum_of_ab < 10:
				counter += matches[sum_of_ab]
				break
		print(counter)


x = int(input())
while x != 0:
	hmm = 0
	(a, b) = map(int, input().split())
	suma = a + b
	while suma != 0:
		n = suma % 10
		if n == 1:
			hmm = 2 + hmm
		elif n == 0 or n == 9 or n == 6:
			hmm = 6 + hmm
		elif n == 2 or n == 3 or n == 5:
			hmm = 5 + hmm
		elif n == 4:
			hmm = 4 + hmm
		elif n == 7:
			hmm = hmm + 3
		else:
			hmm = hmm + 7
		suma = suma // 10
	print(hmm)
	x = x - 1


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	C = A + B
	dict1 = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	C = str(C)
	r = 0
	for i in C:
		r = r + dict1[i]
	print(r)


dict1 = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	sum = a + b
	sum = str(sum)
	count = 0
	for i in sum:
		count += dict1[i]
	print(count)


def return_digits(s):
	i = 10
	digit_lst = []
	while s // 10 != 0:
		ele = s % 10
		digit_lst.append(ele)
		s = s // 10
	digit_lst.append(s)
	return digit_lst
t = int(input())
dict = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
while t > 0:
	(a, b) = map(int, input().split())
	sum = a + b
	digits = return_digits(sum)
	count = 0
	for i in digits:
		count += dict[i]
	print(count)
	t -= 1


T = int(input())
for i in range(T):
	(A, B) = map(int, input().split())
	X = A + B
	Y = list(map(int, str(A + B)))
	Z = []
	for i in Y:
		if i == 0:
			Z.append(6)
		elif i == 1:
			Z.append(2)
		elif i == 2:
			Z.append(5)
		elif i == 3:
			Z.append(5)
		elif i == 4:
			Z.append(4)
		elif i == 5:
			Z.append(5)
		elif i == 6:
			Z.append(6)
		elif i == 7:
			Z.append(3)
		elif i == 8:
			Z.append(7)
		elif i == 9:
			Z.append(6)
	sum = 0
	for j in Z:
		sum = sum + j
	print(sum)


T = int(input())
while T > 0:
	(A, B) = map(int, input().split())
	C = A + B
	count = 0
	mydict = {0: 6, 1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
	while C != 0:
		temp = C % 10
		count += mydict[temp]
		C = C // 10
	print(count)
	T = T - 1


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	sum = l[0] + l[1]
	c = 0
	x = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
	while sum != 0:
		x1 = sum % 10
		c += x[x1]
		sum //= 10
	print(c)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	sumf = a + b
	sums = 0
	while sumf > 0:
		if sumf % 10 == 0 or sumf % 10 == 6 or sumf % 10 == 9:
			sums += 6
		elif sumf % 10 == 1:
			sums += 2
		elif sumf % 10 == 2 or sumf % 10 == 3 or sumf % 10 == 5:
			sums += 5
		elif sumf % 10 == 4:
			sums += 4
		elif sumf % 10 == 7:
			sums += 3
		elif sumf % 10 == 8:
			sums += 7
		sumf = int(sumf / 10)
	print(sums)


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	c = str(A + B)
	e = 0
	d = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	for j in range(len(c)):
		e += d.get(c[j])
	print(e)


c = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	s = a + b
	l = str(s)
	f = 0
	for k in l:
		r = int(k)
		f = f + c[r]
	print(f)


L1 = [2, 3, 5]
L2 = [0, 6, 9]
L3 = [1, 4, 7, 8]
t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	Sum = A + B
	total = 0
	while Sum > 0:
		n = Sum % 10
		Sum = Sum // 10
		if n in L1:
			total = total + 5
		elif n in L2:
			total = total + 6
		elif n == 1:
			total = total + 2
		elif n == 4:
			total = total + 4
		elif n == 8:
			total = total + 7
		else:
			total = total + 3
	print(total)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	r = str(x + y)
	m = len(r)
	s = 0
	for i in range(m):
		if r[i] == '0' or r[i] == '6' or r[i] == '9':
			s += 6
		elif r[i] == '1':
			s += 2
		elif r[i] == '2' or r[i] == '5' or r[i] == '3':
			s += 5
		elif r[i] == '8':
			s += 7
		elif r[i] == '4':
			s += 4
		else:
			s += 3
	print(s)


T = int(input())
for i in range(T):
	(A, B) = [int(x) for x in input().split()]
	result = A + B
	l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
	s = str(result)
	l1 = list(s)
	sum = 0
	for i in l1:
		sum = sum + l[int(i)]
	print(sum)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	z = a + b
	z = str(z)
	sum = 0
	for num in z:
		if num == '0':
			sum = sum + 6
		if num == '1':
			sum = sum + 2
		if num == '2':
			sum = sum + 5
		if num == '3':
			sum = sum + 5
		if num == '4':
			sum = sum + 4
		if num == '5':
			sum = sum + 5
		if num == '6':
			sum = sum + 6
		if num == '7':
			sum = sum + 3
		if num == '8':
			sum = sum + 7
		if num == '9':
			sum = sum + 6
	print(sum)


for i in range(int(input())):
	(A, B) = map(int, input().split(' '))
	Dic = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	C = A + B
	C = str(C)
	D = 0
	for j in C:
		D += Dic[j]
	print(D)


L = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for i in range(int(input())):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	c = str(a + b)
	ans = 0
	for j in c:
		ans += L[int(j)]
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	dic = {'0': 6, '1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}
	c = a + b
	c = str(c)
	count = 0
	for i in c:
		count = count + dic[i]
	print(count)