전광판

전광판

import sys

n = int(sys.stdin.readline())
data = []
for i in range(n):
    data.append(list(sys.stdin.readline().split()))
dic = {"0":63, "1": 6, "2": 91, "3": 79, "4":102, "5": 109, "6": 125, "7": 39, "8": 127, "9": 111}
for li in data:
    a, b = [], []
    for i in li[0]:
        a += [dic[i]]
    for j in li[1]:
        b += [dic[j]]
    la, lb = len(a), len(b)
    lng = min(la, lb)
    a, b = a[::-1], b[::-1]
    ans = 0
    for i in range(lng):
        ans += bin(a[i]^b[i]).count('1')
    if la>lb:
        for i in range(lb, la):
            ans += bin(a[i]).count('1')
    elif la<lb:
        for i in range(la, lb):
            ans += bin(b[i]).count('1')
    print(ans)