for i in range(int(input())):
    num,r = input().split()
    for j in range(int(r)):
        new_num = []
        for i in num:
            new_num.append(int(i)+1)
        num = ""
        for i in new_num:
            num +=str(i)
    print(new_num)
    if 10 in new_num:
        print(len(new_num)+new_num.count(10))
    else:
        print(len(new_num))



