import sys
lights = { '0': [1, 1, 1, 1, 0, 1, 1],
'1': [1, 1, 0, 0, 0, 0, 0],
'2': [1, 0, 1, 1, 1, 0, 1],
'3': [1, 1, 1, 0, 1, 0, 1],
'4': [1, 1, 0, 0, 1, 1, 0],
'5': [0, 1, 1, 0, 1, 1, 1],
'6': [0, 1, 1, 1, 1, 1, 1],
'7': [1, 1, 0, 0, 0, 1, 1],
'8': [1, 1, 1, 1, 1, 1, 1],
'9': [1, 1, 1, 0, 1, 1, 1],
' ': [0, 0, 0, 0, 0, 0, 0]
}
n = int(sys.stdin.readline().rstrip())
for _ in range(n):
a, b = map(int, sys.stdin.readline().split())
str_a = ' '*(5-len(str(a)))+str(a)
str_b = ' '*(5-len(str(b)))+str(b)
cnt = 0
for i in range(len(str_a)):
if str_a[i] != str_b[i]:
for j in range(7):
if lights[str_a[i]][j] != lights[str_b[i]][j]:
cnt += 1
print(cnt)
최대 다섯자리 숫자이므로 두 숫자를 모두 다섯자리로 맞춘다.
이 때, 맨 앞자리에 공백을 붙여 문자열로 만든다.