n = int(input())

for _ in range(n):
    
    keys = input()
    key = keys.split(" ")
    
    val = key[0]
    add = int(key[1])
    
    res = ''
    
    for i in val:
        res += str( int(i)+add)
        
    print(len(res) )