# Python代码,ac过了 t = input() t = int(t) while t > 0: x, y = input().split() x = int(x) y = int(y) num = 0 t -= 1 a = [1, 2, 3, 4, 5, 6, 7, 8, 9] for i in range(9): temp = 0 for j in range(10): temp = temp + a[i] * 10 ** j if x <= temp <= y: num += 1 print(num)