def solve(n):
    number = n[0]
    add = int(n[1])
    _s = ''
    for _ in number:
        _s += str(int(_) + add)

    return len(_s)


case = int(input())
for i in range(case):
    _t = input().split()
    print(solve(_t))