mod = 7000000001 p = [pow(10, i, mod) for i in range(40)] def calc(x): # print(x) if x <= 0: return 0 s = str(x) n = len(s) ans = 0 for l in range(1, n): ans += 45 * p[l - 1] % mod if l > 1: ans += 45 * p[l-2] % mod * (p[l] - 10) % mod dpc = [0, 0] dps = [0, 0] for i in range(n): ndpc = [0, 0] ndps = [0, 0] lim = int(s[i]) if i == 0: ndpc[1] = (lim - 1) ndps[1] = (lim * (lim - 1) // 2) ndpc[0] = 1 ndps[0] = lim else: ndpc[1] += dpc[1] * 10 % mod ndps[1] += dps[1] * 10 + 45 * p[i] % mod * dpc[1] % mod # d < lim ndpc[1] += dpc[0] * lim % mod v = lim * (lim - 1) // 2 ndps[1] += dps[0] * lim + v * p[i] * dpc[0] % mod ndpc[0] += dpc[0] % mod ndps[0] += dps[0] + lim * p[i] % mod * dpc[0] % mod dpc = [x%mod for x in ndpc] dps = [x%mod for x in ndps] return ans + sum(dps) import sys input = sys.stdin.readline # import codecs n = int(input().replace('\u202e', '')) for i in range(n): l, r = [int(x.replace('\u202e', '')) for x in input().split()] x = calc(r) - calc(l - 1) # print(l, r) x = x % mod print(str(x))