import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class test {
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		// Reading data using readLine
		int n = Integer.parseInt(reader.readLine());
		long[] a = new long[2];
		for (int i = 0; i < n; i++) {
			String resultStr = "";
			String[] inputNumber = reader.readLine().split(" ");
			a[0] = Integer.parseInt(inputNumber[0]);
			a[1] = Integer.parseInt(inputNumber[1]);
			
			int oprationCnt = 0;
			
			while(oprationCnt < a[1]) {
				while(a[0] > 0) {
					int plusNum = (int) (a[0] % 10);
					a[0] /= 10;
					
					resultStr = Integer.toString(plusNum + 1) + resultStr;
				}
			
				oprationCnt++;
			}
			
			System.out.println(resultStr.length());
		}
	}
}