Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef is trying to open the oven in his kitchen to cook some cookies. However, the oven is special ― you need a password to open it.

Let's define a function $f(x)$ for a positive integer $x$ as follows:
Consider the decimal representation of $x$ (without leading zeros). Split it into the minimum number of contiguous subsequences of digits such that in each subsequence, all digits are identical.
For each subsequence, look at its position in the original decimal representation of $x$. Let's say that the most significant digit it contained was the $e$-th digit, where $e=0$ corresponds to the least significant digit of $x$. For example, $388,822,442$ can be split into subsequences "3", "888", "22", "44", "2", where $e=7$ for the sequence "888" and $e=4$ for the sequence "22".
The *value* of a subsequence which contains a digit $d$ repeated one or more times is $d \cdot 10^{e}$.
$f(x)$ is the sum of values of these subsequences. For example, $f(388,822,442) = 3 \cdot 10^{8} + 8 \cdot 10^{7} + 2 \cdot 10^{4} + 4 \cdot 10^{2} + 2 \cdot 10^{0}$.

The oven has a screen which displays two long integers $L$ and $R$ (with $N_{L}$ and $N_{R}$ digits respectively, without leading zeros). The password is the sum of $f(x)$ for each $x$ between $L$ and $R$ inclusive.

Chef does not have a lot of time, so he asks for your help. Please find the password for the oven so that he can start cooking as fast as possible. Since this number could be very large, compute it modulo $10^{9} + 7$.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains two space-separated integers $N_{L}$ and $L$.
The second line contains two space-separated integers $N_{R}$ and $R$.

------  Output ------
For each test case, print a single line containing one integer ― the password.

------  Constraints ------
$1 ≤ T ≤ 10$
$1 ≤ N_{L}, N_{R} ≤ 10^{5}$
$1 ≤ L ≤ R < 10^{100,000}$
$L$ and $R$ do not contain leading zeros

------  Subtasks ------
Subtask #1 (10 points):
$R - L ≤ 10^{5}$
$R < 10^{18}$

Subtask #2 (20 points): $R < 10^{18}$

Subtask #3 (70 points): original constraints

----- Sample Input 1 ------ 
3
1 9
2 97
1 8
2 12
1 1
1 8
----- Sample Output 1 ------ 
4681
49
36
----- explanation 1 ------ 
Example case 2: $f(8) = 8, f(9) = 9, f(10) = 10, f(11) = 10, f(12) = 12$

Difficulty: VERY_HARD
Tags: Dynamic programming

Mathematics
Skill types: Dynamic programming

Starter code:

Solutions:
def ti(c):
	return ord(c) - ord('0')
MOD = 1000000007
t = int(input())
for _ in range(t):
	l = input().split()
	ll = int(l[1]) - 1
	l = str(ll)
	r = input().split()
	r = r[1]

	def ans(s):
		(p, sum1) = (1, 0)
		s = s[::-1]
		s2 = 0
		(sp, sx) = (1, 1)
		for i in range(1, len(s)):
			si = ti(s[i])
			si1 = ti(s[i - 1])
			if i != 1:
				sp = sp * 10 % MOD
			if i >= 2:
				s2 = (s2 + ti(s[i - 2]) * sx % MOD) % MOD
				sx = sx * 10 % MOD
			spi = sp * si % MOD
			sum1 = (sum1 + spi * (spi - 1) // 2 % MOD) % MOD
			if si1 > si:
				sum1 = (sum1 + spi * sp % MOD) % MOD
			elif si1 == si:
				if i != 1:
					str2 = s2 + 1
					sum1 = (sum1 + spi * str2 % MOD) % MOD
				else:
					sum1 = (sum1 + si) % MOD
			p -= 1
		return sum1
	sl = ans(l)
	sr = ans(r)
	nl = ll * (ll + 1) // 2 % MOD
	rr = int(r)
	rn = rr * (rr + 1) // 2 % MOD
	print((rn - sr - (nl - sl)) % MOD)


mod = 1000000007
a = [0, 1]
for i in range(2, 100008):
	a.append(a[i - 1] * 10 % mod)
b = [0, 0, 45]
for i in range(3, 100008):
	b.append((b[i - 1] * 100 + a[i - 1] * 45) % mod)

def calca(r):
	(su1, pre_m, ppm) = (0, 0, 0)
	for i in range(len(r)):
		m = int(r[-1 - i])
		if pre_m > m:
			mi = m * m * b[i] + a[i] * (m * (m - 1)) // 2 + a[i] * a[i] * m
		elif pre_m == m:
			mi = m * m * b[i] + a[i] * (m * (m - 1)) // 2 + pre_m * a[i] * (ppm + 1)
		else:
			mi = m * m * b[i] + a[i] * (m * (m - 1)) // 2
		su1 -= mi
		su1 = su1 % mod
		ppm = (pre_m * a[i] + ppm) % mod
		pre_m = m
	return su1
for t in range(int(input())):
	(NL, L) = map(int, input().rstrip().split())
	(NR, R) = map(int, input().rstrip().split())
	l = str(L - 1)
	r = str(R)
	su1 = calca(r)
	su2 = calca(l)
	su1 = R * (R + 1) // 2 + su1
	su2 = L * (L - 1) // 2 + su2
	su1 = su1 % mod
	su2 = su2 % mod
	print(int(su1 - su2) % mod)


mod = 1000000007

def mulmod(a, b):
	a = a % mod
	b = b % mod
	res = a * b % mod
	return res

def fx(d, s):
	if d < 2:
		sigma_xMinusFx = 0
	else:
		sigma_xMinusFx = 0
		j = 0
		ten_pow_j_mod = 1
		while j < d - 1:
			i = j + 2
			k = j + 1
			n1 = int(s[-j - 2])
			n2 = int(s[-j - 1])
			ten_pow_2j_mod = mulmod(ten_pow_j_mod, ten_pow_j_mod)
			if j > 0:
				n4 = n3 % mod
				n3 = n2 * ten_pow_j_mod + n3
			else:
				n4 = 1
				n3 = n2 + 1
			if n2 > n1:
				l1 = mulmod(n1, ten_pow_2j_mod)
			elif n2 == n1 and n2 > 0:
				n5 = mulmod(ten_pow_j_mod, n4)
				l1 = mulmod(n1, n5)
			else:
				l1 = 0
			x1 = 45 * n1
			x4 = n1 * (n1 - 1) // 2
			if k == 1:
				x2 = 0
			elif k == 2:
				x2 = 1
				x3 = 1
			else:
				x3 = mulmod(100, x3)
				x2 = mulmod(10, x2)
				x2 = (x2 + x3) % mod
			l2 = mulmod(x1, x2)
			l3 = mulmod(x4, ten_pow_2j_mod)
			sigma_xMinusFx = (sigma_xMinusFx + l1 + l2 + l3) % mod
			ten_pow_j_mod = mulmod(10, ten_pow_j_mod)
			j += 1
	n = int(s)
	if int(s[-1]) % 2 == 1:
		a = (n + 1) // 2
		b = n
	else:
		a = n // 2
		b = n + 1
	a = a % mod
	b = b % mod
	sigma_x = mulmod(a, b)
	f_x = (sigma_x - sigma_xMinusFx) % mod
	return f_x
t = int(input())
for _ in range(t):
	(nl, l) = input().split()
	(nr, r) = input().split()
	nr = int(nr)
	l = str(int(l) - 1)
	nl = len(l)
	fx_r = fx(nr, r)
	fx_l = fx(nl, l)
	f_x = (fx_r - fx_l) % mod
	print(f_x)


def diff(str1, str2):
	if isSmaller(str1, str2):
		str3 = ''
		(str1, str2) = (str2, str1)
		n1 = len(str1)
		n2 = len(str2)
		str1 = str1[-1::-1]
		str2 = str2[-1::-1]
		carry = 0
		for i in range(n2):
			sub = ord(str1[i]) - ord('0') - (ord(str2[i]) - ord('0')) - carry
			if sub < 0:
				sub += 10
				carry = 1
			else:
				carry = 0
			str3 = str3 + str(sub)
		for i in range(n2, n1):
			sub = ord(str1[i]) - ord('0') - carry
			if sub < 0:
				sub += 10
				carry = 1
			else:
				carry = 0
			str3 = str3 + str(sub)
		str3 = str3[-1::-1]
		return str3

def isSmaller(str1, str2):
	n1 = len(str1)
	n2 = len(str2)
	if n1 < n2:
		return True
	if n2 < n1:
		return False
	for i in range(n1):
		if str1[i] < str2[i]:
			return True
		elif str1[i] > str2[i]:
			return False
	return False

def encoding(num1, n1, mod, pre_power, pre_num):
	ans = 0
	key = 0
	for i in range(n1 - 1, -1, -1):
		cur = int(num1[i])
		length = n1 - i
		if length - 2 > 0:
			tmp1 = pre_power[length - 3] * cur % mod
			tmp1 = tmp1 * 9 % mod
			tmp2 = pre_num[length - 3] * tmp1 % mod
			tmp2 = tmp2 * 45 % mod
			ans = (ans + tmp2) % mod
		if length - 1 > 0:
			for j in range(1, 10, 1):
				if j >= cur:
					tmp1 = j * pre_power[length - 2] % mod
					tmp2 = pre_power[length - 2] * cur % mod
					ans = (ans + tmp1 * tmp2 % mod) % mod
				else:
					tmp1 = j * pre_power[length - 2] % mod
					tmp2 = pre_power[length - 2] * (cur - 1) % mod
					ans = (ans + tmp1 * tmp2 % mod) % mod
		if length > 0:
			tmp1 = pre_power[length - 1]
			for j in range(1, cur, 1):
				tmp2 = j * tmp1 % mod
				ans = (ans + tmp1 * tmp2 % mod) % mod
			store = 0
			if i + 1 < n1:
				store = int(num1[i + 1]) * pre_power[n1 - i - 2] % mod
				store = (store + key) % mod
				key = store
			if i > 0 and num1[i] == num1[i - 1]:
				pass
			else:
				tmp2 = cur * tmp1
				if i + 1 < n1:
					tmp3 = store
					ans = (ans + tmp2 * (store + 1) % mod) % mod
				else:
					ans = (ans + tmp2) % mod
	tmp = 0
	cnt = 0
	for i in range(n1 - 1, 0, -1):
		cur = int(num1[i])
		key = int(num1[i - 1])
		if cur > key:
			tmp = (tmp + key * (pre_power[cnt] * pre_power[cnt]) % mod % mod) % mod
		cnt += 1
	return (ans - tmp) % mod
precomp_power = []
mod = 10 ** 9 + 7
for i in range(10 ** 5 + 1):
	precomp_power.append(pow(10, i, mod))
precomp_num = [1]
for i in range(1, 10 ** 5 + 3):
	precomp_num.append((precomp_num[i - 1] * 10 + 1) % mod)
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(nl, num1) = list(map(str, input().split()))
	(nr, num2) = list(map(str, input().split()))
	nl = int(nl)
	nr = int(nr)
	if num1 == '1':
		ans2 = encoding(num2, nr, mod, precomp_power, precomp_num)
		print(ans2 % mod)
	else:
		num1 = diff('1', num1)
		ans1 = encoding(num1, nl, mod, precomp_power, precomp_num)
		ans2 = encoding(num2, nr, mod, precomp_power, precomp_num)
		print((ans2 - ans1) % mod)


mod = 10 ** 9 + 7

def modinv(b):
	return pow(b, mod - 2, mod)
modinv9 = modinv(9)

def f(x, nx):
	prev = x[0]
	fx = int(x[0]) * pow(10, nx - 1, mod) % mod
	for i in range(1, nx):
		if x[i] != prev:
			prev = x[i]
			fx = (fx + int(x[i]) * pow(10, nx - i - 1, mod)) % mod
	return fx % mod

def calc_sumfx(x, n):
	sum_fx = 0
	total = 1
	for i in range(n - 1, -1, -1):
		d = int(x[i])
		p = n - i
		p1 = pow(10, p - 1, mod)
		if p >= 2:
			p2 = pow(10, p - 2, mod)
			p3 = pow(10, max(p - 3, 0), mod)
			FX = 0
			pnc = int(d * 9 * p3) % mod
			power = (p2 - 1) % mod * modinv9 % mod
			fx = pnc * power * 45 % mod
			ap = d * (d - 1) // 2
			p22 = p2 * p2 % mod
			fx = (fx + (ap * (d - 1) + (45 - ap) * d) * p22 % mod) % mod
			p11 = p1 * p1 % mod
			p1t = p1 * total % mod
			fx = (fx + (ap * p1 + d * total) % mod * p1 % mod) % mod
			prev = int(x[i - 1]) if i > 0 else None
			if bool(prev):
				if prev < d:
					fx = (fx - prev * p11 % mod) % mod
				elif prev == d:
					fx = (fx - prev * p1t % mod) % mod
			FX = (FX + fx) % mod
		else:
			FX = 0
			for xx in range(1, d + 1):
				if n >= 2 and int(x[-2]) == xx:
					continue
				FX = (FX + xx) % mod
		total = (total + d * p1) % mod
		sum_fx = (sum_fx + FX) % mod
	return sum_fx
for _ in range(int(input())):
	(nl, l) = input().split()
	nl = int(nl)
	(nr, r) = input().split()
	nr = int(nr)
	vall = calc_sumfx(l, nl)
	valr = calc_sumfx(r, nr)
	val = f(l, nl)
	optimum = (valr - vall + val) % mod
	print(optimum)


import re
p = 10 ** 9 + 7
dp = {}

def power_mod(x, y):
	if (x, y) in dp:
		return dp[x, y]
	if y == 0:
		return 1
	ans = x * power_mod(x, y - 1) % p
	dp[x, y] = ans
	return ans

def countall(x):
	x = str(x)
	n = len(x)
	prods = []
	prod = 0
	finalsum = 0
	for i in range(n - 1, 0, -1):
		prod += int(x[i]) * power_mod(10, n - i - 1)
		prod %= p
		prods.append(prod + 1)
		subsum = 0
		subsum += int(x[i]) * (int(x[i]) - 1) // 2
		subsum -= int(x[i - 1]) * (int(x[i]) - 1 >= int(x[i - 1]))
		subsum -= int(x[i - 1]) * (int(x[i - 1]) - 1) // 2 % p
		while subsum < 0:
			subsum += p
		subsum = subsum * power_mod(10, 2 * (n - i - 1)) % p
		if int(x[i - 1]) != int(x[i]):
			if i == n - 1:
				subsum += int(x[i])
			else:
				subsum += int(x[i]) * prods[n - 2 - i] * power_mod(10, n - i - 1)
		finalsum += subsum
		if i < n - 1:
			if i == n - 2:
				finalsum += 45 * int(x[i])
			else:
				finalsum += 45 * int(x[i]) * ((11 * power_mod(10, n - i - 2) - 1) * power_mod(10, n - i - 3))
		finalsum %= p
	finalsum += int(x[0]) * (int(x[0]) - 1) // 2 * power_mod(10, 2 * (n - 1))
	finalsum %= p
	if 0 < n - 1:
		if 0 == n - 2:
			finalsum += 45 * int(x[0])
		else:
			finalsum += 45 * int(x[0]) * ((11 * power_mod(10, n - 2) - 1) * power_mod(10, n - 3))
	if n != 1:
		finalsum += int(x[0]) * prods[n - 2] * power_mod(10, n - 1)
	else:
		finalsum += int(x[0])
	finalsum %= p
	return finalsum

def unicalc(x):
	x = str(x)
	n = len(x)
	ans = 0
	prev = 0
	for i in range(len(x)):
		if int(x[i]) != prev:
			ans += int(x[i]) * power_mod(10, n - i - 1)
			ans %= p
			prev = int(x[i])
	return ans
for _ in range(int(input())):
	(nl, l) = input().split(' ')
	(nr, r) = input().split(' ')
	nl = int(nl)
	if l[-1] != '0':
		l = l[0:nl - 1] + str(int(l[-1]) - 1)
	else:
		s = re.search('[123456789]{1}[0]*$', l)
		l = l[0:nl - len(s.group(0))] + str(int(l[nl - len(s.group(0))]) - 1) + '9' * (len(s.group(0)) - 1)
	print(int((countall(r) - countall(l) + p) % p))


t = int(input())
M = 1000000007
tsum = [0] * 100001
tsum[1] = 0
tsum[2] = 45
for i in range(3, 100001):
	tsum[i] = (45 % M * pow(100, i - 2, M) % M % M + 10 * tsum[i - 1] % M) % M
for _ in range(t):
	d1 = 0
	d2 = 0
	(n, s1) = map(str, input().split())
	(m, s2) = map(str, input().split())
	n = int(n)
	m = int(m)
	a1 = [0] * (n + 1)
	a2 = [0] * (m + 1)
	for i in range(1, len(a1)):
		a1[i] = ord(s1[i - 1]) - ord('0')
	for i in range(1, len(a2)):
		a2[i] = ord(s2[i - 1]) - ord('0')
	n1 = [0] * (n + 1)
	n2 = [0] * (m + 1)
	n1[n] = a1[n]
	n2[m] = a2[m]
	i = n - 1
	while i >= 1:
		n1[i] = (n1[i + 1] % M + a1[i] % M * pow(10, n - i, M) % M % M) % M
		i = i - 1
	i = m - 1
	while i >= 1:
		n2[i] = (n2[i + 1] % M + a2[i] % M * pow(10, m - i, M) % M % M) % M
		i = i - 1
	i = 0
	for i in range(1, n):
		if a1[i] == 0:
			continue
		if i == 1:
			d1 = (d1 % M + a1[i] % M * tsum[n - i] % M % M + (a1[i] - 1) * a1[i] // 2 % M * (pow(100, n - i - 1, M) % M) % M) % M
		elif a1[i] < a1[i - 1]:
			d1 = (d1 % M + a1[i] % M * tsum[n - i] % M % M + (a1[i] - 1) * a1[i] // 2 % M * (pow(100, n - i - 1, M) % M) % M) % M
		elif a1[i] == a1[i - 1]:
			d1 = ((d1 % M + a1[i] % M * tsum[n - i] % M % M + (a1[i] - 1) * a1[i] // 2 % M * (pow(100, n - i - 1, M) % M) % M) % M + a1[i - 1] % M * (n1[i + 1] + 1) % M % M % M * pow(10, n - i, M) % M % M) % M
		elif a1[i] > a1[i - 1]:
			d1 = ((d1 % M + a1[i] % M * tsum[n - i] % M % M + (a1[i] - 1) * a1[i] // 2 % M * (pow(100, n - i - 1, M) % M) % M) % M + a1[i - 1] % M * pow(100, n - i, M) % M % M) % M
	if a1[n - 1] <= a1[n]:
		d1 = (d1 % M + a1[n - 1] % M) % M
	for i in range(1, m):
		if a2[i] == 0:
			continue
		if i == 1:
			d2 = (d2 % M + a2[i] % M * tsum[m - i] % M % M + (a2[i] - 1) * a2[i] // 2 % M * (pow(100, m - i - 1, M) % M) % M) % M
		elif a2[i] < a2[i - 1]:
			d2 = (d2 % M + a2[i] % M * tsum[m - i] % M % M + (a2[i] - 1) * a2[i] // 2 % M * (pow(100, m - i - 1, M) % M) % M) % M
		elif a2[i] == a2[i - 1]:
			d2 = ((d2 % M + a2[i] % M * tsum[m - i] % M % M + (a2[i] - 1) * a2[i] // 2 % M * (pow(100, m - i - 1, M) % M) % M) % M + a2[i - 1] % M * (n2[i + 1] + 1) % M % M % M * pow(10, m - i, M) % M % M) % M
		elif a2[i] > a2[i - 1]:
			d2 = ((d2 % M + a2[i] % M * tsum[m - i] % M % M + (a2[i] - 1) * a2[i] // 2 % M * (pow(100, m - i - 1, M) % M) % M) % M + a2[i - 1] % M * pow(100, m - i, M) % M % M) % M
	if a2[m - 1] <= a2[m]:
		d2 = (d2 % M + a2[m - 1] % M) % M
	number = 0
	i = n
	while i >= 2:
		if a1[i] != a1[i - 1]:
			number = (number % M + a1[i] % M * pow(10, n - i, M) % M % M) % M
		i = i - 1
	number = (number % M + a1[1] % M * pow(10, n - 1, M) % M % M) % M
	now1 = (d2 % M - d1 % M + M) % M
	now2 = (n2[1] % M * (n2[1] + 1) % M % M - n1[1] % M * (n1[1] + 1) % M % M + M) % M * 500000004 % M
	final = (now2 % M - now1 % M + M) % M
	soln = (final % M + number % M) % M
	print(soln)


modul = 10 ** 9 + 7
div2 = 500000004
mul = []
for i in range(100005):
	mul.append(1) if i == 0 else mul.append(mul[i - 1] * 10 % modul)
test = int(input())
while test:
	(nl, lst) = map(str, input().split())
	(nr, rst) = map(str, input().split())
	nl = int(nl)
	nr = int(nr)
	temp = ''
	lst = lst[::-1]
	rst = rst[::-1]
	i = 0
	while lst[i] == '0':
		temp += '9'
		i += 1
	if lst[i] != '1':
		temp += str(int(lst[i]) - 1)
	else:
		temp += '0'
	lst = temp + lst[i + 1:]
	total = 0
	l = []
	for i in range(len(lst)):
		total = (total + mul[i] * int(lst[i])) % modul
		l.append(total)
	number = int(lst[0]) * mul[0] % modul
	total1 = number * (number + 1) * div2 % modul
	t = 0
	for i in range(len(lst)):
		if lst[i] == '0' or i == 0:
			continue
		number = int(lst[i]) * mul[i] % modul
		number1 = int(lst[i]) * mul[i - 1] % modul
		t = number * (number + 1) * div2 % modul - number1 * (number1 - 1) * div2 % modul
		temp = int(lst[i]) * mul[i] * l[i - 1] % modul
		if lst[i] == lst[i - 1]:
			if i != 1:
				total1 = (t + temp + (total1 - int(lst[i]) * mul[i - 1] * (int(l[i - 2]) + 1))) % modul
			else:
				total1 = (t + temp + (total1 - int(lst[i]) * mul[i - 1])) % modul
		elif lst[i] > lst[i - 1]:
			total1 += t + temp
			total1 %= modul
		else:
			total1 = (t + temp + (total1 - int(lst[i]) * mul[i - 1] * mul[i - 1])) % modul
	total = 0
	r = []
	for i in range(nr):
		total = (total + mul[i] * int(rst[i])) % modul
		r.append(total)
	number = int(rst[0]) * mul[0] % modul
	total2 = number * (number + 1) * div2 % modul
	for i in range(len(rst)):
		if rst[i] == '0' or i == 0:
			continue
		number = int(rst[i]) * mul[i] % modul
		number1 = int(rst[i]) * mul[i - 1] % modul
		t = number * (number + 1) * div2 % modul - number1 * (number1 - 1) * div2 % modul
		temp = int(rst[i]) * mul[i] * r[i - 1] % modul
		if rst[i] == rst[i - 1]:
			if i != 1:
				total2 = (t + temp + (total2 - int(rst[i]) * mul[i - 1] * (int(r[i - 2]) + 1))) % modul
			else:
				total2 = (t + temp + (total2 - int(rst[i]) * mul[i - 1])) % modul
		elif rst[i] > rst[i - 1]:
			total2 += t + temp
			total2 %= modul
		else:
			total2 = (t + temp + (total2 - int(rst[i]) * mul[i - 1] * mul[i - 1])) % modul
	Ans = (total2 - total1) % modul
	print(Ans)
	test -= 1


duskadum = []
duskadum.append(1)
moddd = 1000000007
for i in range(1, 100005):
	duskadum.append(duskadum[i - 1] * 10 % moddd)
mod2 = 500000004

def funn(n, m):
	ss = n * duskadum[m] % moddd
	aa = ss * (ss + 1) * mod2 % moddd
	if m > 0:
		aa -= n * duskadum[m - 1] * (n * duskadum[m - 1] - 1) * mod2 % moddd
	return aa
t = int(input())
for _ in range(t):
	(nl, l) = map(str, input().split())
	(nr, r) = map(str, input().split())
	nl = int(nl)
	nr = int(nr)
	l = l[::-1]
	i = 0
	sse = ''
	while int(l[i]) == 0:
		i += 1
		for jjj in range(10):
			jj = jjj - 1 * jjj
		sse += '9'
	if nl == 1234321:
		while 1 != 1:
			print('sdfgh')
	if nl == i + 1 and int(l[i]) == 1:
		l = sse + str(int(l[i]) - 1)
	elif nl == i + 1:
		l = sse + str(int(l[i]) - 1)
	else:
		l = sse + str(int(l[i]) - 1) + l[i + 1:]
	r = r[::-1]
	for jjj in range(10):
		jj = jjj - 1 * jjj
	preL = []
	preR = []
	s = 0
	for j in range(nl):
		if j == 1234321:
			abc = 123
			while 1 != 1:
				print('sdfgh')
		s = (s + duskadum[j] * int(l[j])) % moddd
		preL.append(s)
	s = 0
	for j in range(nr):
		if j == 1234321:
			while 1 != 1:
				print('sdfgh')
		s = (s + duskadum[j] * int(r[j])) % moddd
		preR.append(s)
	for j in range(nl):
		if j == 0:
			A1 = funn(int(l[j]), j)
			continue
		if j == 1234321:
			abc = 123
			while 1 != 1:
				print('sdfgh')
		s = funn(int(l[j]), j)
		temp = int(l[j]) * duskadum[j] % moddd
		temp = temp * preL[j - 1] % moddd
		for jjj in range(10):
			jj = jjj - 1 * jjj
		if int(l[j]) < int(l[j - 1]):
			A1 = (s + temp + (A1 - int(l[j]) * duskadum[j - 1] * duskadum[j - 1])) % moddd
		elif int(l[j]) == int(l[j - 1]) and j != 1:
			A1 = (s + temp + (A1 - int(l[j]) * duskadum[j - 1] * (preL[j - 2] + 1))) % moddd
		elif int(l[j]) == int(l[j - 1]) and j == 1:
			A1 = (s + temp + (A1 - int(l[j]) * duskadum[j - 1])) % moddd
		else:
			A1 = (s + temp + A1) % moddd
	for j in range(nr):
		if j == 0:
			A2 = funn(int(r[0]), 0)
			continue
		if j == 1234321:
			abc = 123
			while 1 != 1:
				print('sdfgh')
		s = funn(int(r[j]), j)
		temp = int(r[j]) * duskadum[j] % moddd
		temp = temp * preR[j - 1] % moddd
		for jjj in range(10):
			jj = jjj - 1 * jjj
		if int(r[j]) < int(r[j - 1]):
			A2 = (s + temp + (A2 - int(r[j]) * duskadum[j - 1] * duskadum[j - 1])) % moddd
		elif int(r[j]) == int(r[j - 1]) and j != 1:
			A2 = (s + temp + (A2 - int(r[j]) * duskadum[j - 1] * (preR[j - 2] + 1))) % moddd
		elif int(r[j]) == int(r[j - 1]) and j == 1:
			A2 = (s + temp + (A2 - int(r[j]) * duskadum[j - 1])) % moddd
		else:
			A2 = (s + temp + A2) % moddd
	print((A2 - A1) % moddd)


def f(num):
	sigma = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]
	n = len(num)
	if n == 1:
		return 0
	memoR = [None] * n
	memoR[n - 2] = {'lSum': 0}
	for i in range(n - 3, -1, -1):
		lSum = memoR[i + 1]['lSum'] * 10 + num[i + 2]
		lSum %= MOD
		memoR[i] = {'lSum': lSum}
	memoR[0]['pow'] = 1
	for i in range(1, n - 1):
		power = memoR[i - 1]['pow'] * 10
		power %= MOD
		memoR[i]['pow'] = power
	memoR[0]['rSum'] = 0
	for i in range(1, n - 1):
		rSum = num[i - 1] * memoR[i - 1]['pow'] % MOD + memoR[i - 1]['rSum']
		rSum %= MOD
		memoR[i]['rSum'] = rSum
	ans = 0
	for i in range(0, n - 1):
		d = None
		if num[i] <= num[i + 1]:
			d = num[i + 1] - 1
		else:
			d = num[i + 1]
		if d >= 0:
			occ = (memoR[i]['lSum'] + 1) * memoR[i]['pow'] % MOD
			ans += occ * sigma[d] % MOD * memoR[i]['pow'] % MOD
			ans %= MOD
		d += 1
		if num[i] == num[i + 1] and num[i] == d:
			occ = (memoR[i]['lSum'] * memoR[i]['pow'] % MOD + memoR[i]['rSum'] + 1) % MOD
			ans += occ * d % MOD * memoR[i]['pow'] % MOD
			ans %= MOD
			d += 1
		if d >= 10:
			continue
		occ = memoR[i]['lSum'] * memoR[i]['pow'] % MOD
		ans += occ * (45 - sigma[d - 1]) % MOD * memoR[i]['pow'] % MOD
		ans %= MOD
	return ans
t = int(input())
MOD = 1000000007
while t:
	t -= 1
	(nL, l) = input().split()
	nL = int(nL)
	l = [int(li) for li in l]
	l = l[::-1]
	(nR, r) = input().split()
	nR = int(nR)
	r = [int(ri) for ri in r]
	r = r[::-1]
	r_mod = 0
	power = 1
	for i in r:
		r_mod += i * power % MOD
		r_mod %= MOD
		power *= 10
		power %= MOD
	l_mod = 0
	power = 1
	for i in l:
		l_mod += i * power % MOD
		l_mod %= MOD
		power *= 10
		power %= MOD
	ans = None
	if r_mod % 2:
		ans = (r_mod + 1) // 2
		ans %= MOD
		ans *= r_mod
		ans %= MOD
	else:
		ans = r_mod // 2
		ans %= MOD
		ans *= (r_mod + 1) % MOD
		ans %= MOD
	ans2 = None
	if l_mod % 2:
		ans2 = (l_mod - 1) // 2
		ans2 %= MOD
		ans2 *= l_mod % MOD
		ans2 %= MOD
	else:
		ans2 = l_mod // 2
		ans2 %= MOD
		ans2 *= (l_mod - 1) % MOD
		ans2 %= MOD
	ans -= ans2
	if l[0] != 0:
		l[0] -= 1
	else:
		for i in range(0, nL):
			if l[i] == 0:
				l[i] = 9
			else:
				l[i] -= 1
				break
	temp = (f(r) - f(l)) % MOD
	ans -= temp
	ans %= MOD
	print(ans)


env = 500000004
mod = 1000000007
deca = []
deca.append(1)
for i in range(1, 100005):
	deca.append(deca[i - 1] * 10 % mod)

def myfun(n, m):
	s = n * deca[m] % mod
	a = s * (s + 1) * env % mod
	b = 0
	if m != 0:
		b = n * deca[m - 1] * (n * deca[m - 1] - 1) * env % mod
	s = (a - b) % mod
	return s
t = int(input())
for ii in range(t):
	(nl, l) = map(str, input().split())
	(nr, r) = map(str, input().split())
	nl = int(nl)
	nr = int(nr)
	l = l[::-1]
	i = 0
	se = ''
	while int(l[i]) == 0:
		i += 1
		se += '9'
	if nl == i + 1 and int(l[i]) == 1:
		l = se + str(int(l[i]) - 1)
	elif nl == i + 1:
		l = se + str(int(l[i]) - 1)
	else:
		l = se + str(int(l[i]) - 1) + l[i + 1:]
	r = r[::-1]
	lst = []
	rst = []
	s = 0
	m = 0
	for j in range(nl):
		s = (s + deca[m] * int(l[j])) % mod
		lst.append(s)
		m += 1
	s = 0
	m = 0
	for j in range(nr):
		s = (s + deca[m] * int(r[j])) % mod
		rst.append(s)
		m += 1
	s = 0
	Ans1 = myfun(int(l[0]), 0)
	for j in range(1, nl):
		if int(l[j]) == 0:
			continue
		s = myfun(int(l[j]), j)
		tt = int(l[j]) * deca[j] * lst[j - 1] % mod
		if int(l[j]) < int(l[j - 1]):
			Ans1 = (s + tt + (Ans1 - int(l[j]) * deca[j - 1] * deca[j - 1])) % mod
		elif int(l[j]) == int(l[j - 1]) and j != 1:
			Ans1 = (s + tt + (Ans1 - int(l[j]) * deca[j - 1] * (lst[j - 2] + 1))) % mod
		elif int(l[j]) == int(l[j - 1]):
			Ans1 = (s + tt + (Ans1 - int(l[j]) * deca[j - 1])) % mod
		else:
			Ans1 = (s + tt + Ans1) % mod
	s = 0
	Ans2 = myfun(int(r[0]), 0)
	for j in range(1, nr):
		if int(r[j]) == 0:
			continue
		s = myfun(int(r[j]), j)
		tt = int(r[j]) * deca[j] * rst[j - 1] % mod
		if int(r[j]) < int(r[j - 1]):
			Ans2 = (s + tt + (Ans2 - int(r[j]) * deca[j - 1] * deca[j - 1])) % mod
		elif int(r[j]) == int(r[j - 1]) and j != 1:
			Ans2 = (s + tt + (Ans2 - int(r[j]) * deca[j - 1] * (rst[j - 2] + 1))) % mod
		elif int(r[j]) == int(r[j - 1]):
			Ans2 = (s + tt + (Ans2 - int(r[j]) * deca[j - 1])) % mod
		else:
			Ans2 = (s + tt + Ans2) % mod
	print((Ans2 - Ans1) % mod)


mod = 10 ** 9 + 7
import math

def modulo(num, a):
	res = 0
	for i in range(0, len(num)):
		res = (res * 10 + int(num[i])) % a
	return res

def longDivision(number, divisor):
	if number == '0':
		return '0'
	ans = ''
	idx = 0
	temp = ord(number[idx]) - ord('0')
	while temp < divisor:
		temp = temp * 10 + ord(number[idx + 1]) - ord('0')
		idx += 1
	idx += 1
	while len(number) > idx:
		ans += chr(math.floor(temp // divisor) + ord('0'))
		temp = temp % divisor * 10 + ord(number[idx]) - ord('0')
		idx += 1
	ans += chr(math.floor(temp // divisor) + ord('0'))
	if len(ans) == 0:
		return '0'
	return ans

def findSum(str1, str2):
	if len(str1) > len(str2):
		t = str1
		str1 = str2
		str2 = t
	str = ''
	n1 = len(str1)
	n2 = len(str2)
	str1 = str1[::-1]
	str2 = str2[::-1]
	carry = 0
	for i in range(n1):
		sum = ord(str1[i]) - 48 + (ord(str2[i]) - 48 + carry)
		str += chr(sum % 10 + 48)
		carry = int(sum / 10)
	for i in range(n1, n2):
		sum = ord(str2[i]) - 48 + carry
		str += chr(sum % 10 + 48)
		carry = int(sum / 10)
	if carry:
		str += chr(carry + 48)
	str = str[::-1]
	return str

def power(number, b):
	a = 1
	while b > 0:
		if b & 1:
			a = a * number % mod
		b >>= 1
		number = number * number % mod
	return a

def stringtonumber(a):
	answer = int((ord(a[0]) - 48) * 10 + (ord(a[1]) - 48))
	return answer

def step1(size, string, ending, beginning, array):
	a = 0
	for i in range(1, size):
		number = stringtonumber(string[i - 1] + string[i])
		for j in range(0, 10):
			end = 11 * j
			begin = 11 * j
			x = 11 * j
			if i == 1:
				begin = 0
			else:
				begin = beginning[i - 2]
			end = array[size - i - 1]
			if x < number:
				begin = begin + 1
			a = (a + end % mod * (begin % mod) % mod * (j * array[size - i - 1] % mod) % mod) % mod
			if x == number:
				if i == size - 1:
					a += array[size - i - 1] * j % mod
				else:
					a += j * array[size - i - 1] % mod * (ending[i + 1] + 1) % mod
			a %= mod
	return a
small = 0
large = 0
difference1 = 0
difference2 = 0
largesum = 0
smallsum = 0
answer = 0
flag = 0
array = [0] * 100001
array[0] = 1
for i in range(1, 100001):
	array[i] = array[i - 1] * 10 % mod
a = int(input())
for i in range(a):
	(nl, l) = input().split()
	(nr, r) = input().split()
	nl = int(nl)
	nr = int(nr)
	firstend = [0] * (nr + 1)
	secondend = [0] * (nl + 1)
	firstbegin = [0] * (nr + 1)
	secondbegin = [0] * (nl + 1)
	firstend[nr - 1] = ord(r[nr - 1]) - 48
	firstbegin[0] = ord(r[0]) - 48
	secondend[nl - 1] = ord(l[nl - 1]) - 48
	secondbegin[0] = ord(l[0]) - 48
	small = 0
	large = 0
	smallsum = 0
	largesum = 0
	answer = 0
	flag = 0
	for i in range(1, nl):
		secondbegin[i] = (secondbegin[i - 1] * 10 + ord(l[i]) - 48) % mod
	for i in range(1, nr):
		firstbegin[i] = (firstbegin[i - 1] * 10 + ord(r[i]) - 48) % mod
	for i in range(nl - 2, -1, -1):
		secondend[i] = ((ord(l[i]) - 48) * array[nl - (i + 1)] % mod + secondend[i + 1]) % mod
	for i in range(nr - 2, -1, -1):
		firstend[i] = ((ord(r[i]) - 48) * array[nr - (i + 1)] % mod + firstend[i + 1]) % mod
	for i in range(nl - 1, -1, -1):
		small = ((ord(l[i]) - 48) * array[nl - (i + 1)] % mod + small) % mod
	for i in range(nr - 1, -1, -1):
		large = ((ord(r[i]) - 48) * array[nr - (i + 1)] % mod + large) % mod
	difference1 = step1(nr, r, firstend, firstbegin, array)
	difference2 = step1(nl, l, secondend, secondbegin, array)
	largesum = large * (large + 1) % mod
	smallsum = small * (small + 1) % mod
	largesum = (largesum * power(2, mod - 2) % mod - difference1 + mod) % mod
	smallsum = (smallsum * power(2, mod - 2) % mod - difference2 + mod) % mod
	for i in range(nl - 1, 0, -1):
		if l[i] == l[i - 1]:
			continue
		flag = flag + (ord(l[i]) - 48) * array[nl - (i + 1)] % mod
		flag = flag % mod
	flag = (flag + (ord(l[0]) - 48) * array[nl - 1] % mod) % mod
	answer = (largesum - smallsum + flag + mod) % mod
	print(answer)


prime = 1000000007
lim = 100005
p10cache = [1]
for _ in range(1, lim):
	p10cache.append(10 * p10cache[-1] % prime)
tricache = [0]
for i in range(1, lim):
	tricache.append((i + tricache[-1]) % prime)
tgpcache = [0]
for i in range(1, lim):
	tgpcache.append(5 * (p10cache[i] - 1) % prime)

def p10(n):
	return p10cache[n]

def tri(n):
	return tricache[n]

def tgp(n):
	return tgpcache[n]

def decr(l):
	i = 0
	while l[i] == 0:
		l[i] = 9
		i += 1
	l[i] -= 1

def get_sum(l):
	prefix_nums = [1]
	num = 1
	base = 1
	for d in l:
		num += base * d
		num %= prime
		prefix_nums.append(num)
		base *= 10
		base %= prime
	c = len(l) - 1
	s = 0
	while c:
		if l[c] > 0:
			s += tri(l[c] - 1) * p10(c - 1) * p10(c - 1)
		if c > 1:
			s += l[c] * tgp(c - 1) * p10(c - 2)
		if l[c] == l[c - 1]:
			s += l[c] * p10(c - 1) * prefix_nums[c - 1]
		elif l[c] < l[c - 1]:
			s += l[c] * p10(c - 1) * p10(c - 1)
		c -= 1
		s %= prime
	ts = prefix_nums[-1] * (prefix_nums[-1] - 1) >> 1
	return (ts + prime - s) % prime
t = int(input())
for _ in range(t):
	l = list(map(int, reversed(input().split()[1])))
	decr(l)
	sol_n = get_sum(l)
	l = list(map(int, reversed(input().split()[1])))
	sol_m = get_sum(l)
	print((sol_m - sol_n) % prime)


import sys
import math
from sys import stdin, stdout
m = int(1000000007)

def digit(s):
	p = 0
	for i in range(0, len(s)):
		p = (p % m * 10 % m + int(s[i]) % m) % m
	return p

def pfs(s, a):
	a.append(0)
	p = 0
	for i in range(1, len(s)):
		p = (p % m * 10 % m + int(s[i - 1]) % m) % m
		a.append(p)

def sus(s, a):
	p = 0
	for i in range(len(s) - 2, -1, -1):
		q = int(s[i + 1]) % m * pow(10, len(s) - i - 2, m) % m
		p = (p % m + q % m) % m
		a.append(p)
	a.append(0)

def calculate(s, modinv):
	a = []
	b = []
	pfs(s, a)
	sus(s, b)
	ans = 0
	for i in range(1, len(s)):
		x = pow(10, len(s) - 1 - i, m)
		ans += a[i - 1] % m * pow(x % m, 2, m) % m * 45 % m % m
		if s[i - 1] > s[i]:
			p = int(s[i - 1])
			ans += p % m * (p - 1) % m % m * modinv % m % m * pow(x % m, 2, m) % m % m
		elif s[i - 1] < s[i]:
			p = int(s[i - 1])
			ans += p % m * (p + 1) % m % m * modinv % m % m * pow(x % m, 2, m) % m
		else:
			p = int(s[i - 1])
			ans += (p % m * (p - 1) % m % m * modinv % m % m * pow(x % m, 2, m) + p % m * (x % m) % m * (b[len(s) - i - 2] % m + 1) % m) % m
	z = digit(s) % m
	y = (z % m * (z + 1) % m * modinv % m % m - ans % m) % m
	return y

def main():
	m = 1000000007
	modinv = 500000004
	t = int(stdin.readline())
	while t > 0:
		t -= 1
		(n, L1) = map(str, stdin.readline().split())
		(m, R1) = map(str, stdin.readline().split())
		L = list(L1)
		R = list(R1)
		for i in range(len(L) - 1, -1, -1):
			if L[i] == '0':
				L[i] = '9'
			else:
				tum = int(L[i])
				tum -= 1
				zum = str(tum)
				L[i] = zum
				break
		kk1 = calculate(L, modinv)
		kk = calculate(R, modinv)
		ans = (kk % 1000000007 - kk1 % 1000000007) % 1000000007
		print(ans)
sys.exit(main())


mod = lambda x: int(x) % int(1000000000.0 + 7)
MV = int(1000000000.0 + 7)
summer = {}
mogra = {}

def getSum(a, b):
	a = int(a)
	b = int(b)
	if (a, b) in summer.keys():
		return summer[a, b]
	ans = 0
	for i in range(a, b + 1):
		ans += i
	summer[a, b] = ans
	return ans

def getMiners(num):
	num = num[::-1]
	miners = []
	prev = 1
	i = 0
	for n in num[:-1]:
		prev += int(n) * pow(10, i, MV)
		prev = mod(prev)
		i += 1
		miners.append(prev)
	return miners

def merger(boy, n):
	mid = n // 2
	a = boy[:mid]
	b = boy[mid:]
	lef = n - mid
	for i in range(lef):
		a.append('0')
	a = int(''.join(a))
	b = int(''.join(b))
	a = mod(a)
	b = mod(b)
	return a + b

def val(a):
	num = str(a)
	n = len(num)
	if n == 1:
		return a
	prev = num[0]
	ans = 0
	boy = [prev]
	for i in range(1, n):
		if num[i - 1] == num[i]:
			boy.append('0')
		else:
			boy.append(num[i])
	ans = merger(boy, n)
	return ans

def solve(a, b):
	temo = mogra.get((a, b), -1)
	if temo != -1:
		return temo
	a = int(a)
	b = int(b)
	ans = 0
	for i in range(a, b + 1):
		ans += val(i)
		ans = mod(ans)
	mogra[str(a), str(b)] = ans
	return ans

def hetroSolve(a, b):
	n = len(a)
	temo = mogra.get((a, b), -1)
	if temo != -1:
		return temo
	if n <= 3:
		temp = solve(a, b)
		return temp
	miners = getMiners(b)
	nexSub = miners.pop()
	ans = 0
	po = n - 1
	a1 = mod(int(b[0]) * nexSub * pow(10, po, MV))
	po -= 1
	smsb = int(b[1])
	miner = miners.pop()
	a2 = 0
	if smsb == int(b[0]):
		cutter = pow(10, po, MV)
		a2 = mod(getSum(1, smsb - 1) * cutter * cutter)
	else:
		strt = 1
		endd = smsb - 1
		hlfSum = 0
		if endd != 0:
			hlfSum = getSum(strt, endd)
			if int(a[0]) in [j for j in range(strt, endd + 1)]:
				hlfSum -= int(a[0])
		a2 = mod(hlfSum * pow(10, po, MV) * pow(10, po, MV))
		a2 += mod(smsb * miner * pow(10, po, MV))
	po -= 1
	ans = mod(a1 + a2)
	if po == -1:
		return ans
	prev = int(smsb)
	i = 2
	extraMul = 1
	matru = prev * pow(10, po, MV)
	delta = 1 * pow(10, po, MV)
	while po > -1:
		curr = int(b[i])
		cutter = pow(10, po, MV)
		miner = 0
		if i + 1 != n:
			miner = miners.pop()
		if prev > curr:
			if curr + 1 == prev and po != 0:
				s1 = mod((getSum(1, 9) - curr) * matru)
				m3 = 0
				if po > 0:
					m3 = miner
				s2 = mod(curr * (matru - cutter + miner))
				temp = mod((s1 + s2) * pow(10, po, MV))
				ans += temp
			elif po == 0:
				s1 = mod((getSum(1, curr) + getSum(prev, 9)) * matru)
				s2 = mod(getSum(curr + 1, prev - 1) * (matru - cutter))
				temp = mod((s1 + s2) * pow(10, po, MV))
				ans += temp
			else:
				head = 0
				if curr != 1:
					head = getSum(1, curr - 1)
				elif curr == 1 and po == 0:
					head = 1
				s1 = mod((head + getSum(prev, 9)) * matru)
				s2 = mod(getSum(curr + 1, prev - 1) * (matru - cutter))
				s3 = mod(curr * (matru - cutter))
				if po == 0 and curr == 1:
					s3 = 0
				if po > 0:
					s3 += mod(curr * miner)
				temp = mod((s1 + s2 + s3) * pow(10, po, MV))
				ans += temp
		elif prev < curr:
			if po == 0:
				s1 = mod(getSum(prev + 1, curr) * (matru + cutter))
				s2 = mod((getSum(1, prev) + getSum(curr + 1, 9)) * matru)
				temp = mod((s1 + s2) * pow(10, po, MV))
				ans += temp
			elif prev + 1 == curr:
				s1 = mod((getSum(1, 9) - curr) * matru)
				m3 = 0
				if po > 0:
					m3 = miner
				s2 = mod(curr * (matru + miner))
				temp = mod((s1 + s2) * pow(10, po, MV))
				ans += temp
			else:
				s1 = mod((getSum(1, prev) + getSum(curr + 1, 9)) * matru)
				s2 = mod(getSum(prev + 1, curr - 1) * (matru + cutter))
				s3 = 0
				if po > 0:
					s3 = mod(curr * (matru + miner))
				temp = mod((s1 + s2 + s3) * pow(10, po, MV))
				ans += temp
		else:
			s1 = mod(getSum(1, 9) * matru)
			temp = mod(s1 * pow(10, po, MV))
			ans += temp
		dpo = 0
		if po != 0:
			dpo = po - 1
		delta = mod(abs(curr - prev) * pow(10, dpo, MV))
		if prev < curr:
			matru += delta
		elif prev > curr:
			matru -= delta
		prev = curr
		i += 1
		po -= 1
		ans = mod(ans)
	mogra[a, b] = mod(ans)
	return mod(ans)

def fullEndHelp(a, b):
	temo = mogra.get((a, b), -1)
	if temo != -1:
		return temo
	na = len(a) - 1
	nb = len(b)
	ans = 0
	temp = pow(10, nb - 1, MV)
	a1 = mod(temp * temp)
	ite = nb - na
	temp = pow(10, nb - 2, MV)
	smsb = mod(9 * temp)
	gpsum = 0
	for kpo in range(ite - 1):
		gpsum += pow(10, nb - 2 - kpo, MV)
	a2 = mod(smsb * gpsum)
	ans += mod(a1 + a2)
	po = na - 1
	duma3 = mod(smsb - pow(10, po, MV))
	a3 = mod(duma3 * pow(10, po, MV))
	ans += a3
	if po == 0:
		return mod(45 * ans)
	po -= 1
	duma4 = mod(duma3 + pow(10, po, MV))
	a4 = mod(duma4 * pow(10, po, MV))
	ans += a4
	po -= 1
	temp = 0
	while po != -1:
		temp += pow(10, po, MV)
		temp = mod(temp)
		po -= 1
	temo = mod(45 * (ans + temp * duma4))
	mogra[a, b] = temo
	return temo

def getSplitSumE2E(prevA, prevB):
	if prevA == 1 and prevB == 9:
		return (0, 45 * 8)
	elif prevA > 1 and prevB < 9:
		s1 = getSum(1, prevA - 1)
		s2 = getSum(prevB + 1, 9)
		unmixSum = s1 + s2
		unmixLen = prevA - 1 + (9 - prevB)
		mixSum = getSum(prevA, prevB)
		mixLen = prevB - prevA + 1
		return (unmixSum * mixLen, mixSum * (mixLen - 1))
	elif prevA > 1:
		unmixSum = getSum(1, prevA - 1)
		unmixLen = prevA - 1
		mixSum = getSum(prevA, prevB)
		mixLen = prevB - prevA + 1
		return (unmixSum * mixLen, mixSum * (mixLen - 1))
	else:
		unmixSum = getSum(prevB + 1, 9)
		unmixLen = 9 - prevB
		mixSum = getSum(prevA, prevB)
		mixLen = prevB - prevA + 1
		return (unmixSum * mixLen, mixSum * (mixLen - 1))

def endToEnd(locS, locE):
	n = len(locS)
	a = int(locS[0])
	b = int(locE[0])
	temo = mogra.get((locS, locE), -1)
	if temo != -1:
		return temo
	if n <= 2:
		temp = solve(locS, locE)
		return temp
	po = n - 1
	ans = 0
	a1 = mod(getSum(a, b) * pow(10, po, MV) * pow(10, po, MV))
	po -= 1
	(unmix, mix) = getSplitSumE2E(a, b)
	a2 = mod((mix + unmix) * pow(10, po, MV) * pow(10, po, MV))
	ans = mod(a1 + a2)
	po -= 1
	niner = mod(45 * 9 * (b - a + 1) * pow(10, po, MV))
	gpsum = 0
	while po != -1:
		gpsum += pow(10, po, MV)
		po -= 1
	ans += mod(niner * gpsum)
	mogra[locS, locE] = ans
	return ans

def delegate(a, b, na, nb):
	if len(a) == len(b):
		if na == 1:
			temp = getSum(a, b)
			return temp
		if na == 2:
			return solve(int(a), int(b))
		return endToEnd(a, b)
	else:
		endA = '9' * na
		startB = '1' + '0' * na
		if a[0] != '1' or nb - na < 5:
			return endToEnd(a, endA) + delegate(startB, b, na + 1, nb)
		else:
			partyA = a
			partyB = '9' * (nb - 1)
			disco = '1' + '0' * (nb - 1)
			ans1 = fullEndHelp(a, partyB)
			if len(b) < len(disco) or disco == b:
				ans2 = 0
			else:
				ans2 = endToEnd(disco, b)
			return mod(ans1 + ans2)

def gt(a, b):
	if len(a) > len(b):
		return True
	if len(a) == len(b) and a > b:
		return True
	return False

def mixerGrinder(a, b, na, nb):
	startA = a[0] + '0' * (na - 1)
	oppo = ''
	vivo = str(int(b[0]) - 1)
	if vivo != '0':
		oppo = vivo
	endB = oppo + '9' * (nb - 1)
	startB = b[0] + '0' * (nb - 1)
	endSub = str(int(a) - 1)
	a = endSub
	partialAns = 0
	additionAns = 0
	if gt(startA, endB):
		partialAns = 0
	else:
		partialAns = delegate(startA, endB, na, nb)
	if gt(endSub, startA):
		subtracAns = hetroSolve(startA, endSub)
	else:
		subtracAns = 0
	if len(b) < len(startB) or (len(b) == len(startB) and b < startB):
		additionAns = 0
	else:
		additionAns = hetroSolve(startB, b)
	return mod(partialAns + additionAns - subtracAns)
for _ in range(int(input())):
	(la, a) = input().split()
	(lb, b) = input().split()
	ans = 0
	if int(la) < 2 and int(lb) > 2:
		ans += getSum(a, 9)
		a = '10'
		la = 2
	if len(b) < 3:
		ans += solve(a, b)
	elif la == lb and a == b:
		ans += solve(a, b)
	else:
		ans += mixerGrinder(a, b, int(la), int(lb))
	print(ans)


sums = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]
MOD = 10 ** 9 + 7

def solve(X):
	diff = 0
	temp = X % MOD
	x = str(X)
	num = 0
	N = len(x)
	i = N - 2
	trailingNum = 0
	while i >= 0:
		if x[i] < x[i + 1]:
			diff += powModArr[2 * (N - 2 - i)] * sums[int(x[i])] % MOD
		elif x[i] == x[i + 1]:
			if i == N - 2:
				diff += sums[int(x[i])]
			else:
				diff += (powModArr[2 * (N - 2 - i)] * sums[int(x[i]) - 1 + (x[i] == '0')] + powModArr[N - 2 - i] * int(x[i]) * (trailingNum + 1)) % MOD
		else:
			diff += powModArr[2 * (N - 2 - i)] * sums[int(x[i]) - 1 + (x[i] == '0')] % MOD
		trailingNum = (trailingNum + int(x[i + 1]) * powModArr[N - 2 - i]) % MOD
		i -= 1
	i = 0
	while i < N - 1:
		diff += powModArr[2 * (N - 2 - i)] * (45 * num) % MOD
		num = (num * 10 + int(x[i])) % MOD
		i += 1
	return (temp * (temp + 1) * 500000004 % MOD - diff + MOD) % MOD
T = int(input())
powModArr = [1]
for i in range(2 * 10 ** 5 + 1):
	temp = powModArr[-1] * 10 % MOD
	powModArr.append(temp)
while T > 0:
	T -= 1
	(Nl, L) = list(map(int, input().split(' ')))
	(Nr, R) = list(map(int, input().split(' ')))
	print(int(solve(R) - solve(L - 1) + MOD) % MOD)
exit(0)


import math
import sys
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from sys import stdin, stdout
from collections import defaultdict
inp = lambda : int(stdin.readline())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, stdin.readline().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
MOD = pow(10, 9) + 7

def modmult(a, b):
	ans = a % MOD * (b % MOD) % MOD
	return ans

def make_list(s):
	l = []
	for i in s:
		l.append(int(i))
	return l

def make_dict():
	s = 0
	d[0] = 0
	for i in range(1, 100):
		if i % 11 == 0:
			s += i // 11
		d[i] = s

def make_product():
	product = 1
	for i in range(1, 200005):
		product = product * 10 % MOD
		pw[i] = product

def make_mult():
	multi[3] = 110
	for i in range(4, 100100):
		multi[i] = modmult(multi[i - 1], 100) + pw[i - 2]
		multi[i] %= MOD

def cal_minus(num, p):
	if p == 0:
		return d[num]
	elif p == 1:
		return d[num * 10]
	elif p == 2:
		a = (45 * pow(num, 2) + num * (num - 1) // 2 * 10) % MOD
		return a
	else:
		a = modmult(45 * pow(num, 2), multi[p]) + modmult(num * (num - 1) // 2, pw[p - 1])
		return a

def minus_upto(l):
	n = len(l)
	repeat = 0
	sm = cal_minus(l[0], n - 1)
	for i in range(1, n):
		cal = cal_minus(l[i], n - 1 - i)
		if l[i] > l[i - 1]:
			sm += modmult(l[i - 1], modmult(pw[n - 1 - i], pw[n - i - 1])) + cal + modmult(repeat, l[i] * pw[n - i - 1])
		elif l[i] < l[i - 1]:
			sm += cal + modmult(repeat, l[i] * pw[n - i - 1])
		elif l[i] == l[i - 1]:
			sm += cal + modmult(repeat, l[i] * pw[n - i - 1])
			repeat += modmult(l[i], pw[n - i - 1])
			repeat = repeat % MOD
	sm += repeat
	sm = sm % MOD
	return sm
d = {}
pw = [1] * 200005
multi = [1] * 100100
make_dict()
make_product()
make_mult()
for _ in range(int(input())):
	(nl, L) = mulip()
	(nr, R) = mulip()
	L = L - 1
	l = make_list(str(L))
	r = make_list(str(R))
	sumL = L % MOD * ((1 + L) % MOD) % MOD
	sumL = sumL * pow(2, MOD - 2, MOD) % MOD
	sumL = sumL - minus_upto(l) % MOD
	sumR = R % MOD * ((1 + R) % MOD) % MOD
	sumR = sumR * pow(2, MOD - 2, MOD) % MOD
	sumR = sumR - minus_upto(r) % MOD
	print((sumR - sumL) % MOD)


import time
MOD = 1000000007

def getP(num):
	nw = 0
	x = 0
	while num // 10 > 0:
		if num % 10 != num // 10 % 10:
			nw += num % 10 * 10 ** x
		num //= 10
		x += 1
	nw += num * 10 ** x
	return nw

def getPLast(num):
	nw = 0
	x = 0
	while num // 10 > 0:
		if num % 10 != num // 10 % 10:
			nw += num % 10 * 10 ** x
		num //= 10
		x += 1
	nw += num * 10 ** x
	return nw % 10

def getFpl(n, fpl):
	if n < 0:
		return 0
	return fpl[n]

def do(n, fpl, fmin):
	orig = n
	pos = 0
	carry = 0
	ans = 0
	while n > 0:
		wholeNo = (n // 100 * fpl[99] + getFpl(n % 100 - 1, fpl)) * 10 ** pos + fmin[n % 100] * (orig % 10 ** pos + 1) + carry
		lastDigit = wholeNo % 10
		carry = wholeNo // 10
		ans += lastDigit * 10 ** pos
		pos += 1
		n //= 10
	ans += carry * 10 ** pos
	return ans

def do2(n, fpl, fmin, powarr):
	orig = n
	pos = 0
	carry = 0
	ans = 0
	pan = 0
	ss = time.time()
	lastDigit = 0
	qq = 0
	divb = 1
	while n > 0:
		jj = n // 100 % MOD * fpl[99] + getFpl(n % 100 - 1, fpl)
		qq = orig % divb % MOD
		divb *= 10
		nn = jj % MOD * powarr[pos] % MOD
		f_a = fmin[n % 100] * ((qq + 1) % MOD)
		wholeNo = (nn + f_a + carry) % MOD
		carry = wholeNo // 10
		lastDigit = wholeNo % 10
		ans = (ans + wholeNo % 10 * powarr[pos]) % MOD
		pos += 1
		n //= 10
	ans += carry * powarr[pos]
	print('>>>>>>>>>>>>>>', time.time() - ss, pos)
	return ans % MOD

def do3(n, fpl, fmin, powarr):
	orig = n
	stn = str(n)
	pos = 0
	carry = 0
	ans = 0
	pan = 0
	ss = time.time()
	lastDigit = 0
	qq = 0
	divb = 0
	old = time.time()
	while n > 0:
		lastTwo = int(stn[max(0, len(stn) - pos - 2):len(stn) - pos])
		if lastTwo == 0:
			jj = n // 100 % MOD * fpl[99] % MOD
		else:
			jj = n // 100 % MOD * fpl[99] % MOD + fpl[lastTwo - 1]
		qq = (qq + lastDigit * divb) % MOD
		divb = divb * 10 % MOD
		if divb == 0:
			divb = 1
		nn = jj % MOD * powarr[pos] % MOD
		f_a = fmin[lastTwo] * ((qq + 1) % MOD)
		wholeNo = (nn + f_a + carry) % MOD
		carry = wholeNo // 10 % MOD
		lastDigit = lastTwo % 10
		ans = (ans + wholeNo % 10 * powarr[pos]) % MOD
		pos += 1
		n //= 10
		if pos % 10000 == 0:
			now = time.time()
			print('lol', now - old)
			old = now
	ans += carry * powarr[pos]
	print('>>>>>>>>>>>>>>', time.time() - ss, pos)
	return ans % MOD

def do4(n, fpl, fmin, powarr):
	arrPre = []
	orig = n
	stn = str(n)
	l = 0
	for u in range(100):
		arrPre.append(0)
	for u in range(len(stn)):
		l *= 10
		l %= MOD
		l += int(stn[u])
		l %= MOD
		arrPre.append(l)
	pos = 0
	carry = 0
	ans = 0
	pan = 0
	lastDigit = 0
	qq = 0
	divb = 0
	for oo in range(len(stn)):
		lastTwo = int(stn[max(0, len(stn) - pos - 2):len(stn) - pos])
		if lastTwo == 0:
			jj = arrPre[-3 - pos] * fpl[99] % MOD
		else:
			jj = arrPre[-3 - pos] * fpl[99] % MOD + fpl[lastTwo - 1]
		qq = (qq + lastDigit * divb) % MOD
		divb = divb * 10 % MOD
		if divb == 0:
			divb = 1
		nn = jj % MOD * powarr[pos] % MOD
		f_a = fmin[lastTwo] * ((qq + 1) % MOD)
		wholeNo = (nn + f_a + carry) % MOD
		carry = wholeNo // 10 % MOD
		lastDigit = lastTwo % 10
		ans = (ans + wholeNo % 10 * powarr[pos]) % MOD
		pos += 1
	ans += carry * powarr[pos]
	return ans % MOD
fpl = []
fmin = []
smt = 0
for i in range(100):
	pr = getPLast(i)
	smt += pr
	fpl.append(smt)
	fmin.append(pr)
powarr = []
pt = 1
for i in range(100005):
	powarr.append(pt % MOD)
	pt *= 10
	pt %= MOD
t = int(input())
for tt in range(t):
	(nl, l) = list(map(int, input().split()))
	(nr, r) = list(map(int, input().split()))
	answ3 = (do4(r, fpl, fmin, powarr) - do4(l - 1, fpl, fmin, powarr)) % MOD
	print(answ3)


from sys import stdin
MOD = 10 ** 9 + 7

def f(x, n):
	prev = ''
	final = 0
	for (i, c) in enumerate(x):
		if c != prev:
			power = n - i - 1
			final = (final + int(c) * power10[power]) % MOD
		prev = c
	return final

def g(xi, i, n, prevNum, laterNum):
	power = n - i - 1
	current = int(xi) % MOD
	value = power10[power]
	vvalue = value * value % MOD
	firstPart = prevNum * 45 * vvalue % MOD
	secondPartHalf = (current - 1) * current // 2 % MOD
	secondPart = secondPartHalf * vvalue % MOD
	thirdPartHalf = current * value % MOD
	thirdPart = thirdPartHalf * (laterNum + 1) % MOD
	return (firstPart + secondPart + thirdPart) % MOD

def h(x, i, n, prevNum, laterNum):
	power = n - i - 1
	if i < 1:
		return 0
	if x[i - 1] < x[i]:
		newV = int(x[i - 1])
		laterNum = star9[power]
	elif x[i - 1] == x[i]:
		newV = int(x[i - 1])
	else:
		newV = int(x[i - 1]) - 1
		laterNum = star9[power]
	return g(newV, i - 1, n - 1, prevNum, laterNum)
t = int(stdin.readline())
for _ in range(t):
	inp = stdin.readline().split()
	(nl, L) = (int(inp[0]), inp[1])
	inp = stdin.readline().split()
	(nr, R) = (int(inp[0]), inp[1])
	n = max(nl, nr)
	power10 = [None] * (n + 1)
	power = 1
	for i in range(n + 1):
		power10[i] = power
		power = 10 * power % MOD
	final = 0
	star9 = [None] * (n + 1)
	for i in range(n + 1):
		star9[i] = final
		final = (final * 10 + 9) % MOD
	final = 0
	LprevValues = [None] * nl
	k = 0
	for (i, l) in enumerate(L):
		LprevValues[k] = final
		k += 1
		final = (final * 10 + int(l)) % MOD
	final = 0
	LlaterValues = [None] * nl
	k = nl - 1
	for i in range(nl - 1, -1, -1):
		power = nl - i - 1
		l = L[i]
		LlaterValues[k] = final
		k -= 1
		final = (final + int(l) * power10[power] % MOD) % MOD
	final = 0
	RprevValues = [None] * nr
	k = 0
	for (i, r) in enumerate(R):
		RprevValues[k] = final
		k += 1
		final = (final * 10 + int(r)) % MOD
	final = 0
	RlaterValues = [None] * nr
	k = nr - 1
	for i in range(nr - 1, -1, -1):
		power = nr - i - 1
		r = R[i]
		RlaterValues[k] = final
		k -= 1
		final = (final + int(r) * power10[power] % MOD) % MOD
	count = 0
	for i in range(nr):
		count = (count + g(R[i], i, nr, RprevValues[i], RlaterValues[i]) - h(R, i, nr, RprevValues[i - 1], RlaterValues[i])) % MOD
	for i in range(nl):
		count = (count - g(L[i], i, nl, LprevValues[i], LlaterValues[i]) + h(L, i, nl, LprevValues[i - 1], LlaterValues[i])) % MOD
	print((count + f(L, nl)) % MOD)


m = 1000000007

def power(x, n):
	if n <= 0:
		return 1
	temp = power(x, n // 2)
	temp = temp * temp % m
	if n % 2 == 1:
		temp = temp * x % m
	return temp

def calculate(n, l):
	store = [0] * n
	temp = l
	store = list(str(l))
	li = [0] * n
	for i in range(n):
		store[i] = int(store[i])
		li[i] = store[i]
	temp = 0
	k = 1
	for i in range(n - 1, -1, -1):
		temp = temp % m + store[i] * k % m
		k = k * 10
		k = k % m
		store[i] = temp % m
	ans = 0
	for i in range(n):
		ans1 = 0
		pod = power(10, n - i - 2)
		if n - i - 1 <= 0:
			pod = 0
		pod = pod % m
		x = li[i]
		ans1 = ans1 % m + x * (pod * (pod - 1)) // 2 % m + x * (x - 1) // 2 * (pod * pod) % m
		if i > 0 and li[i] == li[i - 1]:
			if i + 1 < n:
				ans1 = (ans1 % m + x * pod * 10 * (store[i + 1] + 1) % m) % m
			else:
				ans1 = (ans1 + x) % m
		elif i > 0 and li[i] > li[i - 1]:
			pod = power(10, n - i - 1)
			if n - i <= 0:
				pod = 0
			pod = pod % m
			ans1 = (ans1 % m + pod * pod * li[i - 1] % m) % m
		ans = (ans % m + ans1 % m) % m
	return ans
t = int(input())
while t > 0:
	(nl, l) = input().strip().split()
	(nr, r) = input().strip().split()
	nl = int(nl)
	nr = int(nr)
	l = int(l)
	r = int(r)
	l = l - 1
	nl = len(str(l))
	l1 = calculate(nl, l)
	r1 = calculate(nr, r)
	r = r % m
	l = l % m
	total = r * (r + 1) // 2 - l * (l + 1) // 2
	total = (total - (r1 - l1) + m) % m
	print(total)
	t = t - 1


MOD = 1000000007
t = int(input())
for x in range(t):
	t1 = input().split()
	t2 = input().split()
	nl = int(t1[0])
	L = str(t1[1])
	nr = int(t2[0])
	R = str(t2[1])
	l = []
	r = []
	for i in range(len(L)):
		l.append(int(L[i]))
	for i in range(len(R)):
		r.append(int(R[i]))
	s = 0
	a = 1
	temp = r[-1] % MOD
	b1 = pow(2, MOD - 2, MOD) % MOD
	fake_r = 0
	for i in range(nr - 1):
		d = r[-i - 2] % MOD
		N = (d * a % MOD - 1 + MOD) % MOD
		n = N % MOD
		N = (N + 1) % MOD
		n = n * N % MOD
		n = n * b1 % MOD
		s = (s + n) % MOD
		if temp > d:
			g1 = d % MOD
			g1 = g1 * a % MOD
			g1 = g1 * a % MOD
			s = (s + g1) % MOD
		elif temp == d:
			g1 = d % MOD
			g1 = g1 * a % MOD
			g1 = g1 * ((fake_r % MOD + 1) % MOD) % MOD
			s = (s + g1) % MOD
		fake_r = (fake_r + temp * a % MOD % MOD) % MOD
		a = a * 10 % MOD
		temp = d % MOD
	R = int(R) % MOD
	h1 = R % MOD * (R % MOD + 1) % MOD % MOD
	h1 = h1 * b1 % MOD
	finalr = (h1 - s + MOD) % MOD
	s = 0
	a = 1
	temp = l[-1] % MOD
	b1 = pow(2, MOD - 2, MOD) % MOD
	fake_l = 0
	for i in range(nl - 1):
		d = l[-i - 2] % MOD
		N = (d * a % MOD - 1 + MOD) % MOD
		n = N % MOD
		N = (N + 1) % MOD
		n = n * N % MOD
		n = n * b1 % MOD
		s = (s + n) % MOD
		if temp > d:
			g1 = d % MOD
			g1 = g1 * a % MOD
			g1 = g1 * a % MOD
			s = (s + g1) % MOD
		elif temp == d:
			g1 = d % MOD
			g1 = g1 * a % MOD
			g1 = g1 * ((fake_l % MOD + 1) % MOD) % MOD
			s = (s + g1) % MOD
		fake_l = (fake_l + temp * a % MOD % MOD) % MOD
		a = a * 10 % MOD
		temp = d % MOD
	L = int(L) % MOD
	h1 = L % MOD * (L % MOD + 1) % MOD % MOD
	h1 = h1 * b1 % MOD
	finall = (h1 - s + MOD) % MOD
	y = l[0]
	L = 0
	for i in range(1, nl):
		if l[i] == y:
			l[i] = 0
		else:
			y = l[i]
	ptr = 1
	for i in range(nl - 1, -1, -1):
		L = (L % MOD + l[i] * (ptr % MOD)) % MOD
		ptr = ptr * 10 % MOD
	finalr = (finalr + L) % MOD
	print((finalr - finall + MOD) % MOD, end='\n')


mo = 1000000007
li = [1]
for i in range(1, 200001):
	li.append(li[i - 1] % mo * 10 % mo)
t = int(input())
while t:
	(nl, l) = input().split()
	(nr, r) = input().split()
	nr = int(nr)
	l = int(l)
	l -= 1
	l = str(l)
	nl = len(l)
	num = 0
	prev = 0
	pi = (nl - 3) * 2
	su = 0
	m = 1
	mm = 1
	pp = 0
	for i in range(nl):
		if nl - i > 2:
			prev = (prev % mo * 10 % mo + int(l[i])) % mo
			su += prev % mo * 45 * li[pi] % mo % mo
		pi -= 2
		j = nl - i - 1
		if j == nl - 1:
			p = 0
		else:
			p = (li[i - 1] % mo * (int(l[j + 1]) % mo) % mo + num % mo) % mo
			num = p
		if j - 1 >= 0:
			if int(l[j]) < int(l[j - 1]):
				a = int(l[j - 1]) - 1
			elif int(l[j]) > int(l[j - 1]):
				a = int(l[j - 1])
			else:
				a = int(l[j]) - 1
				su += (p + 1) % mo * (li[i] % mo) * int(l[j]) % mo
			su += a * (a + 1) // 2 % mo * (li[pp] % mo) % mo
		pp += 2
	num = 0
	prev = 0
	pi = (nr - 3) * 2
	su1 = 0
	pp = 0
	for i in range(nr):
		if nr - i > 2:
			prev = (prev % mo * 10 % mo + int(r[i])) % mo
			su1 += prev % mo * 45 * (li[pi] % mo) % mo
			pi -= 2
		j = nr - i - 1
		if j == nr - 1:
			p = 0
		else:
			p = (li[i - 1] % mo * (int(r[j + 1]) % mo) % mo + num % mo) % mo
			num = p
		if j - 1 >= 0:
			if int(r[j]) < int(r[j - 1]):
				a = int(r[j - 1]) - 1
			elif int(r[j]) > int(r[j - 1]):
				a = int(r[j - 1])
			else:
				a = int(r[j]) - 1
				su1 += (p + 1) % mo * (li[i] % mo) * int(r[j]) % mo
			su1 += a * (a + 1) // 2 % mo * (li[pp] % mo) % mo
		pp += 2
	print((int(r) * (int(r) + 1) // 2 - su1 - int(l) * (int(l) + 1) // 2 + su) % mo)
	t -= 1


m = 10 ** 9 + 7

def sol(l, r):
	x = l % m * (l + 1) % m % m * pow(2, m - 2, m) % m
	y = r % m * (r + 1) % m % m * pow(2, m - 2, m) % m
	ans = (y - x + m) % m
	return ans
qw = [0]
for i in range(10 ** 5):
	x = (pow(10, i, m) + qw[i]) % m
	qw.append(x)
qw1 = []
for i in range(1, 10 ** 5 + 2):
	x = pow(10, i, m)
	qw1.append(x)
arr1 = []
for i in range(len(qw1)):
	x = qw1[i] * qw1[i] % m
	arr1.append(x)
arr2 = []
for i in range(len(qw1)):
	x = qw1[i] * qw[i] % m * 45 % m
	arr2.append(x)

def solve(ar):
	n = len(ar)
	a = 0
	for i in range(n - 2):
		a = (a * 10 + ar[i]) % m
	return a

def solve1(ar):
	n = len(ar)
	a = [0] * n
	a[0] = ar[0]
	for i in range(n - 1):
		a[i + 1] = ar[i + 1] * qw1[i] % m
	for i in range(n - 1):
		a[i + 1] = (a[i + 1] + a[i]) % m
	return a

def calculate(lll, abc, hrr):
	n = len(hrr)
	x = abc[1] // 11
	y = x * (x + 1) // 2
	ans = (y + lll * 45 % m) % m
	for i in range(0, n - 2):
		if hrr[i + 2] < hrr[i + 1]:
			x = hrr[i + 2]
			y = x * (x + 1) // 2
			ans = (ans + y * arr1[i] + x * arr2[i]) % m
		if hrr[i + 2] > hrr[i + 1]:
			x = hrr[i + 2]
			y = x * (x - 1) // 2
			ans = (ans + y * arr1[i] + x * arr2[i]) % m
		if hrr[i + 2] == hrr[i + 1]:
			x = hrr[i + 2]
			y = x * (x - 1) // 2
			ans = (ans + y * arr1[i] + x * arr2[i] + x * (qw1[i] * (abc[i] + 1)) % m) % m
	return ans % m
t = int(input())
for _ in range(t):
	(nl, l) = list(map(int, input().split()))
	(nr, r) = list(map(int, input().split()))
	l = l - 1
	result = sol(l, r)
	a = [int(i) for i in str(l)]
	xx = solve(a)
	a = a[::-1]
	strl = solve1(a)
	nl = len(str(l))
	ans1 = 0
	if len(strl) > 1:
		ans1 = calculate(xx, strl, a)
	b = [int(i) for i in str(r)]
	xy = solve(b)
	b = b[::-1]
	strr = solve1(b)
	nr = len(str(r))
	ans2 = 0
	if len(strr) > 1:
		ans2 = calculate(xy, strr, b)
	result = (result + ans1 - ans2 + m) % m
	print(result)


from sys import stdin

def F(s):
	if s == '0' or s == '1':
		return int(s)
	M = 10 ** 9 + 7
	n = eval(s) % M
	v = (n * n % M + n) % M
	p = v * pow(2, M - 2, M) % M
	(dpl, dpr) = ([0] * len(s), [0] * len(s))
	a = 0
	for i in range(len(s)):
		dpl[i] = (a * 10 + int(s[i])) % M
		a = dpl[i]
	a = 0
	pow10 = 1
	pm = [1]
	for i in range(len(s) - 1, -1, -1):
		dpr[i] = (a + int(s[i]) * pow10) % M
		a = dpr[i]
		pow10 = pow10 * 10 % M
		pm.append(pow10)
	dpl.append(0)
	dpr.append(0)
	ans = 0
	for k in range(1, len(s)):
		m = pow(10, len(s) - 1 - k, M)
		m = pm[len(s) - 1 - k]
		d = dpl[k - 2] * 45 * m % M
		if s[k] == s[k - 1]:
			h = int(s[k])
			d += ((h - 1) * h // 2 * m + h * (dpr[k + 1] + 1)) % M
			d = d * m % M
		else:
			if int(s[k - 1]) > int(s[k]):
				h = int(s[k - 1]) - 1
			else:
				h = int(s[k - 1])
			d += h * (h + 1) // 2 * m % M
			d = d * m % M
		ans = (ans + d) % M
	return (p - ans + M) % M

def solve(inp):
	M = 10 ** 9 + 7
	(nl, l) = inp().split()
	(nr, r) = inp().split()
	ans = (F(r) - F(str(eval(l) - 1)) + M) % M
	print(ans)

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		solve(inp)
main()


import math
power = [1] * 100001
power10 = [1] * 100001
power[1] = 100
power10[1] = 10
f = [0] * 100001
f[1] = 45
mod = 1000000007
for i in range(2, 100001):
	power[i] = power[i - 1] * 100 % mod
	power10[i] = power10[i - 1] * 10 % mod
	f[i] = (10 * f[i - 1] % mod + f[1] * (power[i - 1] - power[i - 2]) % mod % mod) % mod

def enc(s, mod):
	ret = 0
	l = len(s)
	temp = int(s) % mod
	for i in range(l):
		k = l - i
		b = int(s[i])
		if b == 0:
			continue
		else:
			a = b - 1
			if k == 1:
				tr = b * (b + 1) // 2
				ret = (ret + tr) % mod
			else:
				d = int(s[i + 1])
				tr = a * (a + 1) // 2
				ret = (ret + ((a + 1) * f[k - 1] % mod + tr * (power[k - 1] - power[k - 2]) % mod % mod) % mod) % mod
				temp = (temp - b * power10[k - 1] % mod) % mod
				ret = (ret + b * ((temp + 1) % mod) * power10[k - 1] % mod) % mod
				if b < d:
					ret = (ret - b * power[k - 2] % mod) % mod
				elif b == d:
					if k == 2:
						ret = (ret - b) % mod
					else:
						temp1 = (temp - d * power10[k - 2] % mod) % mod
						ret = (ret - b * power10[k - 2] * ((temp1 + 1) % mod) % mod) % mod
				else:
					floss = 1
	return ret
for t in range(int(input())):
	(nl, l) = input().split()
	(nr, r) = input().split()
	nl = int(nl)
	s = ''
	flag = 0
	for i in range(len(l)):
		if flag == 0:
			if l[nl - i - 1] == '0':
				s = '9' + s
			elif i == nl - 1 and l[0] == '1':
				flag = 1
			else:
				s = str(int(l[nl - i - 1]) - 1) + s
				flag = 1
		else:
			s = l[nl - i - 1] + s
	mod = 1000000007
	if l == '1':
		res = enc(r, mod)
	else:
		res = (enc(r, mod) - enc(s, mod)) % mod
	print(res)


T = int(input())
mod = 10 ** 9 + 7
two = pow(2, mod - 2, mod)

def find(n, s):
	res = 0
	check = set(s)
	if len(check) == 1:
		check = list(check)
		x = int(check[0])
		temp = 0
		for i in range(0, len(s) - 1):
			temp = (temp * 10 + x) % mod
		res = temp * (temp + 1) % mod
		res = res * two % mod
		return int(res)
	n -= 2
	dp = [0] * (len(s) + 1)
	prev = 1
	ex = 0
	for i in range(len(s) - 1, 0, -1):
		temp = int(s[i])
		temp1 = pow(10, ex, mod)
		temp = temp1 * temp % mod
		temp = (temp + prev) % mod
		dp[i - 1] = temp
		ex += 1
		prev = temp
	dp[len(s) - 1] = 1
	for i in range(0, len(s) - 1):
		x = int(s[i])
		p = 1
		if n > 0:
			p = pow(10, n, mod)
		no = x * p % mod
		temp = no * (no - 1) % mod
		temp = temp * two % mod
		res = (res + temp) % mod
		if int(s[i]) < int(s[i + 1]):
			temp = no * p % mod
			res = (res + temp) % mod
		elif int(s[i]) == int(s[i + 1]):
			temp = no * dp[i + 1] % mod
			res = (res + temp) % mod
		n -= 1
	return int(res)

def brute_force(L, R):
	ans = 0
	for i in range(L, R + 1):
		s = str(i)
		p = len(s) - 1
		prev = '$'
		no = 0
		for j in range(0, len(s)):
			if s[j] != prev:
				x = int(s[j])
				temp = x * pow(10, p, mod) % mod
				no = (no + temp) % mod
			p -= 1
			prev = s[j]
		ans = (ans + no) % mod
	print(int(ans))

def optimized(n1, L, n2, R):
	left = 0
	right = 0
	if n1 > 1:
		left = find(n1, str(L))
	if n2 > 1:
		right = find(n2, str(R))
	L = L % mod
	R = R % mod
	L = L * (L + 1) % mod
	L = L * two % mod
	L = (L - left) % mod
	R = R * (R + 1) % mod
	R = R * two % mod
	R = (R - right) % mod
	ans = (R - L) % mod
	print(ans)
while T:
	T -= 1
	(n1, L) = map(int, input().split())
	(n2, R) = map(int, input().split())
	if R - L <= 100005:
		brute_force(L, R)
		continue
	L -= 1
	optimized(n1, L, n2, R)


MOD = 10 ** 9 + 7
two_inv = 500000004
tenpowmod = [1]
for i in range(3 * 10 ** 5):
	tenpowmod.append(tenpowmod[-1] * 10 % MOD)

def losscalc(num, l):
	loss = 0
	modrev = [0]
	n = len(num)
	for i in range(n - 1, -1, -1):
		fromr = n - i - 1
		xval = (int(num[i]) * tenpowmod[fromr] % MOD + modrev[-1]) % MOD
		modrev.append(xval)
	modrev = modrev[::-1]
	modrev.pop()
	for i in range(len(num)):
		cd = int(num[i])
		fromr = len(num) - i - 1
		if fromr == 0:
			loss += 0
		else:
			loss += cd * l[fromr - 1] % MOD
			loss += tenpowmod[2 * (fromr - 1)] * ((cd - 1) * cd) // 2 % MOD
			nd = int(num[i + 1])
			if nd > cd:
				lossmag = tenpowmod[fromr - 1]
				loss += tenpowmod[fromr - 1] * cd * lossmag % MOD
			elif nd == cd:
				lossmag = tenpowmod[fromr - 1]
				if len(num) - (i + 2):
					nn = modrev[i + 2]
				else:
					nn = 0
				loss += (nn + 1) % MOD * cd * lossmag % MOD
		loss %= MOD
	return loss
l = [0]

def precalc():
	for i in range(110000):
		xval = 10 * l[-1] + 45 * tenpowmod[2 * i]
		l.append(xval % MOD)
precalc()

def modstr(s):
	ans = 0
	n = len(s)
	for i in range(n - 1, -1, -1):
		fromr = n - i - 1
		ans += int(s[i]) * tenpowmod[fromr] % MOD
		ans %= MOD
	return ans

def solve(a, b):
	a_mod = modstr(a)
	b_mod = modstr(b)
	s = b_mod * ((b_mod + 1) % MOD) * two_inv % MOD - a_mod * ((a_mod - 1) % MOD) * two_inv % MOD - (losscalc(b, l) % MOD - losscalc(str(int(a) - 1), l) % MOD) % MOD
	return s % MOD
t = int(input())
for __ in range(t):
	(na, a) = input().split()
	(nb, b) = input().split()
	print(solve(a, b))


mod = 10 ** 9 + 7

def getcountsimple(dig, digits, mod):
	num = dig * tens[digits]
	total = num * (num + 1) // 2
	if digits >= 1:
		total -= dig * (dig - 1) // 2 * tens[2 * digits - 2]
	if digits >= 2:
		const = ones[digits - 1] * tens[digits - 2] % mod
		total -= dig * const * 45
	return total % mod

def getcount(digits, num, mod):
	curdig = int(num[0])
	fin = curdig * tens[digits - 1]
	count = getcountsimple(curdig, digits - 1, mod)
	for i in range(digits - 2, -1, -1):
		nextdig = int(num[digits - 2 - i])
		curdig = int(num[digits - 1 - i])
		count += getcountsimple(curdig, i, mod) + fin * curdig * tens[i]
		if curdig > nextdig:
			count -= nextdig * tens[2 * i]
		elif curdig == nextdig:
			count -= nextdig * tens[i]
		if curdig != nextdig:
			fin += curdig * tens[i]
			fin %= mod
		count %= mod
	return count
tens = [1]
ones = [0, 1]
for i in range(1, 200000):
	tens.append(tens[-1] * 10 % (2 * mod))
	ones.append((ones[-1] + tens[-1]) % (2 * mod))
for _ in range(int(input())):
	(nl, l) = list(map(str, input().split()))
	(nr, r) = list(map(str, input().split()))
	(nl, nr) = (int(nl), int(nr))
	l = str(int(l) - 1)
	nl = len(l)
	print((getcount(nr, r, 2 * mod) - getcount(nl, l, mod)) % mod)


import time
import sys
t1 = time.time()
mod = 10 ** 9 + 7

def find_nines(n, nine_answers, i, prev):
	asd = n * (n - 1) // 2
	ans = (n * nine_answers[i - 1] % mod + asd * pow10[i] * pow10[i] % mod - asd * pow10[i - 1] * pow10[i - 1] % mod) % mod
	if n > prev:
		x = prev * pow10[i] * pow10[i]
		ans -= x
		ans %= mod
	return ans
pow10 = []
prod = 1
for i in range(100010):
	pow10 += [prod]
	prod *= 10
	prod %= mod
nine_answers = [45]
for i in range(1, 100010):
	x = (nine_answers[i - 1] * 10 % mod + 45 * pow10[i] * pow10[i] % mod - 45 * pow10[i - 1] * pow10[i - 1] % mod) % mod
	nine_answers += [x]
t = int(input())
for i in range(t):
	(nl, l) = input().split()
	(nr, r) = input().split()
	l = str(int(l) - 1)
	larr = [0] * len(l)
	pp = 0
	for i in range(len(l) - 1, -1, -1):
		larr[i] = (int(l[i]) * pow10[len(l) - i - 1] + pp) % mod
		pp = larr[i]
	ans = 0
	l = str(l)
	prev = 999
	for i in range(1, len(l)):
		n = int(l[i - 1])
		ans += find_nines(n, nine_answers, len(l) - i, prev)
		x = larr[i]
		if n != prev:
			ans2 = n * pow10[len(l) - i] * (x + 1) % mod
		else:
			ans2 = 0
		prev = n
		ans += ans2
		ans %= mod
	n = int(l[-1])
	asd = n * (n + 1) // 2
	ans += asd
	if n >= prev:
		ans -= prev
	ans %= mod
	lans = ans
	rarr = [0] * len(r)
	pp = 0
	for i in range(len(r) - 1, -1, -1):
		rarr[i] = (int(r[i]) * pow10[len(r) - i - 1] + pp) % mod
		pp = rarr[i]
	ans = 0
	prev = 999
	for i in range(1, len(r)):
		n = int(r[i - 1])
		ans += find_nines(n, nine_answers, len(r) - i, prev)
		x = rarr[i]
		if n != prev:
			ans2 = n * pow10[len(r) - i] * (x + 1) % mod
		else:
			ans2 = 0
		prev = n
		ans += ans2
		ans %= mod
	n = int(r[-1])
	asd = n * (n + 1) // 2
	ans += asd
	if n >= prev:
		ans -= prev
	ans %= mod
	rans = ans
	print((rans - lans) % mod)


lis = [0, 45]
lis1 = [0, 1]
m = pow(10, 9) + 7
for i in range(1, pow(10, 5)):
	lis.append((lis[1] * pow(10, 2 * i, m) + lis[i] * 10 % m) % m)
	lis1.append(lis1[1] * pow(10, 2 * i, m) % m)

def reverse(string):
	string = ''.join(reversed(string))
	return string

def sep(lis):
	sr = reverse(lis)
	luck = [int(sr[0]) % m]
	for i in range(1, len(sr)):
		luck.append((luck[i - 1] % m + pow(10, i, m) * int(sr[i])) % m)
	luck.reverse()
	return luck

def count(n):
	return n * (n + 1) // 2 % m

def cal(n, l):
	sum = 0
	if len(n) == 1:
		return 0
	for i in range(len(n) - 1):
		if i == len(n) - 2:
			if int(n[i]) <= int(n[i + 1]):
				sum = (sum + count(int(n[i]))) % m
			else:
				sum = (sum + count(int(n[i]) - 1)) % m
		elif int(n[i]) < int(n[i + 1]):
			sum = (sum + count(int(n[i])) * lis1[len(n) - 1 - i] % m + int(n[i]) * lis[len(n) - 2 - i] % m) % m
		elif int(n[i]) > int(n[i + 1]):
			sum = (sum + count(int(n[i]) - 1) * lis1[len(n) - 1 - i] % m + int(n[i]) * lis[len(n) - 2 - i] % m) % m
		else:
			sum = (sum + count(int(n[i]) - 1) * lis1[len(n) - 1 - i] % m + int(n[i]) * pow(10, len(n) - i - 2, m) * (l[i + 2] + 1) % m + int(n[i]) * lis[len(n) - 2 - i] % m) % m
	return sum
for _ in range(int(input())):
	(l, lr) = map(str, input().split())
	(r, rr) = map(str, input().split())
	l1 = sep(str(int(lr) - 1))
	l2 = sep(rr)
	ans = (count(int(rr)) - count(int(lr) - 1) - (cal(rr, l2) - cal(str(int(lr) - 1), l1))) % m
	print(ans)


M = int(1000000000.0 + 7)
T = [1]
for i in range(int(200000.0)):
	T.append(T[-1] * 10 % M)

def f(n):
	p = 45
	D = int(n[-1])
	q = D * (D + 1) // 2
	r = D
	R = 0
	for k in range(1, len(n)):
		D = int(n[-k - 1])
		q = (D * p + 99 * (D - 1) * D // 2 * T[2 * k - 2] + q + (r + 1) * D * T[k]) % M
		d = int(n[-k])
		if d > D:
			x = T[k - 1]
		elif d == D:
			x = R + 1
		else:
			x = 0
		q = (q - x * D * T[k - 1] % M + M) % M
		p = (10 * p + 4455 * T[2 * k - 2]) % M
		R = r
		r = (D * T[k] + r) % M
	return q

def F(n):
	r = int(n[0]) * T[len(n) - 1]
	for i in range(1, len(n)):
		if n[i] != n[i - 1]:
			r = (r + int(n[i]) * T[len(n) - 1 - i]) % M
	return r
t = int(input())
for tt in range(t):
	l = input().split()[1]
	r = input().split()[1]
	print((f(r) - f(l) + F(l) + M) % M)


MOD = 1000000007

def madd(a, b):
	return a + b - MOD if a + b >= MOD else a + b

def msub(a, b):
	return a - b + MOD if a - b < 0 else a - b

def mmul(a, b):
	return a * b % MOD

def fn(n):
	if n < 10:
		return n * (n + 1) // 2
	s = '00' + str(n)
	N = len(s)
	e = [0 for i in range(N)]
	e[N - 1] = 1
	for i in range(N - 2, -1, -1):
		e[i] = mmul(e[i + 1], 10)
	e2 = [0 for i in range(N)]
	e2[N - 1] = 1
	for i in range(N - 2, -1, -1):
		e2[i] = mmul(e2[i + 1], 100)
	a = [0 for i in range(len(s) + 1)]
	a[N - 1] = int(s[N - 1])
	for i in range(N - 2, -1, -1):
		a[i] = madd(mmul(int(s[i]), e[i]), a[i + 1])
	b = [0 for i in range(len(s))]
	b[0] = int(s[0])
	for i in range(1, N):
		b[i] = madd(mmul(b[i - 1], 10), int(s[i]))
	r = 0
	for i in range(N - 1, 1, -1):
		d = int(s[i - 1])
		for j in range(1, d):
			r = madd(r, mmul(mmul(madd(b[i - 2], 1), j), e2[i]))
		if d < int(s[i]):
			r = madd(r, mmul(mmul(madd(b[i - 2], 1), d), e2[i]))
		elif d >= int(s[i]):
			r = madd(r, mmul(mmul(b[i - 2], d), e2[i]))
		if d == int(s[i]):
			r = madd(r, mmul(mmul(madd(a[i + 1], 1), d), e[i]))
		for j in range(d + 1, 10):
			r = madd(r, mmul(mmul(b[i - 2], j), e2[i]))
	t = n if n % 2 == 1 else n // 2
	u = n + 1 if (n + 1) % 2 == 1 else (n + 1) // 2
	return msub(mmul(t % MOD, u % MOD), r)
T = int(input())
while T > 0:
	tok = input().split(' ')
	L = int(tok[1])
	tok = input().split(' ')
	R = int(tok[1])
	print(msub(fn(R), fn(L - 1)))
	T -= 1


mod = 10 ** 9 + 7
hun = [0 for i in range(10 ** 5 + 2)]
hun[0] = 1
for i in range(1, 10 ** 5 + 2):
	hun[i] = hun[i - 1] * 10 % mod
dp = [[0 for i in range(10)] for j in range(10 ** 5 + 2)]
for i in range(10):
	dp[1][i] = i
for i in range(2, 10 ** 5 + 2):
	for j in range(10):
		dp[i][j] = (sum(dp[i - 1]) + j * hun[i - 1] * hun[i - 1] - j * hun[i - 2] * hun[i - 2]) % mod

def solve(arr):
	ans = 0
	n = len(arr)
	prev = 0
	prenum = 0
	for num in arr:
		ans += sum(dp[n][:num]) % mod
		ans += prev * num * hun[n - 1] % mod
		if prenum < num:
			ans -= prenum * hun[n - 1] * hun[n - 1] % mod
		if prenum != num:
			prev += num * hun[n - 1] % mod
		prenum = num
		n -= 1
	return ans
t = int(input())
for _ in range(t):
	(a, na) = map(int, input().split())
	(b, nb) = map(int, input().split())
	na = list(map(int, str(na)))
	nb = list(map(int, str(nb + 1)))
	print((solve(nb) - solve(na)) % mod)


global p, tp, su
p = 1000000007
tp = [1]
su = [0]

def cal(n, s):
	ps = [s[n - 1]]
	ans = 0
	for i in range(1, n):
		ps.append((ps[i - 1] + s[n - i - 1] * tp[i]) % p)
	if n > 0:
		ans += su[s[0] - 1] * tp[n - 1] * tp[n - 1] % p
		ans += s[0] * (1 if n == 1 else ps[n - 2] + 1) * tp[n - 1] % p
		ans = ans % p
	if n > 1:
		ans += (su[9] * s[0] - su[s[0] - 1]) * tp[n - 2] * tp[n - 2] % p
		ans += (su[max(0, s[1] - 1)] - (s[0] if s[0] < s[1] else 0)) * tp[n - 2] * tp[n - 2] % p
		ans += (0 if s[0] == s[1] else s[1]) * (1 if n == 2 else ps[n - 3] + 1) * tp[n - 2] % p
		ans = ans % p
	if n > 2:
		for i in range(2, n):
			ans += (ps[n - 1] - ps[n - i]) % p * 850000010 * tp[n - i - 1] % p
			ans += (su[9] * s[i - 1] - su[max(0, s[i - 1] - 1)]) * tp[n - i - 1] * tp[n - i - 1] % p
			ans += (su[max(0, s[i] - 1)] - (s[i - 1] if s[i - 1] < s[i] else 0)) * tp[n - i - 1] * tp[n - i - 1] % p
			ans += (0 if s[i - 1] == s[i] else s[i]) * (1 if n == i + 1 else ps[n - i - 2] + 1) * tp[n - i - 1] % p
			ans = ans % p
	return ans
t = int(input())
for i in range(1, 100010):
	tp.append(tp[i - 1] * 10 % p)
for i in range(1, 10):
	su.append(su[i - 1] + i)
for _ in range(t):
	(nl, a) = [str(i) for i in input().split()]
	(nr, b) = [str(i) for i in input().split()]
	nl = int(nl)
	nr = int(nr)
	l = []
	r = []
	for i in range(nl):
		l.append(int(a[i]))
	for i in range(nr):
		r.append(int(b[i]))
	l[nl - 1] -= 1
	o = nl - 1
	while l[o] < 0:
		l[o - 1] -= 1
		l[o] = 9
		o -= 1
	if l[0] == 0:
		nl -= 1
		for i in range(nl):
			l[i] = l[i + 1]
	print((cal(nr, r) - cal(nl, l)) % p)


import sys, os, re, random, itertools, functools, collections

def read_int():
	return int(input())

def read_str_list():
	return input().split()
MOD = int(1000000000.0 + 7)

def count(s):
	s = s[::-1]
	ans = 0
	for i in range(len(s)):
		if i == len(s) - 1 or s[i] != s[i + 1]:
			ans = (ans + int(s[i]) * TEN[i]) % MOD
	return ans

def solve(s):
	s = s[::-1]
	(ans, m) = (0, 0)
	for i in range(len(s)):
		j = int(s[i])
		if i > 0:
			if j == int(s[i - 1]):
				ans = (ans - j * TEN[i - 1] * (m + 1 - j * TEN[i - 1] % MOD + MOD) % MOD + MOD) % MOD
			elif j < int(s[i - 1]):
				ans = (ans - j * TEN[i - 1] * TEN[i - 1] % MOD + MOD) % MOD
			ans = (C[i + 1][j] + j * TEN[i] % MOD * m % MOD + ans) % MOD
		else:
			ans = C[i + 1][j]
		m = (j * TEN[i] + m) % MOD
	return ans
N = 1
cases = []
T = read_int()
while T > 0:
	T -= 1
	(n1, l) = read_str_list()
	(n2, r) = read_str_list()
	N = max(N, int(n1) + 1, int(n2) + 1)
	cases.append((l, r))
TEN = [1]
S = [[0] * 10 for _ in range(N + 1)]
C = [[0] * 10 for _ in range(N + 1)]
for i in range(1, N + 1):
	TEN.append(TEN[-1] * 10 % MOD)
S[1] = list(range(10))
for i in range(2, N + 1):
	for j in range(10):
		d = TEN[i - 1] * j % MOD
		for k in range(10):
			if j == k:
				t = ((d - TEN[i - 2] * j + MOD) % MOD * TEN[i - 2] + S[i - 1][j]) % MOD
			else:
				t = (d * TEN[i - 2] + S[i - 1][k]) % MOD
			S[i][j] = (S[i][j] + t) % MOD
for i in range(1, N + 1):
	for j in range(1, 10):
		C[i][j] = (S[i][j - 1] + C[i][j - 1] + TEN[i - 1]) % MOD
for (l, r) in cases:
	ans = (solve(r) - solve(l) + MOD + count(l)) % MOD
	print(ans)


mod = 1000000007
tenp = []
for i in range(200005):
	tenp.append(pow(10, i, mod))
import math

def modInverse(b, m):
	g = math.gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def modDivide(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -1
	else:
		return inv * a % m

def sumtill(n):
	sr = str(n)
	sum = 0
	one = 1
	p = 1
	if len(sr) >= 3:
		for i in range(len(sr) - 3, -1, -1):
			sum = (sum % mod + int(sr[i]) * one % mod) % mod
			one = one * 100 % mod
			one = (one + tenp[p]) % mod
			p += 1
	sum = sum % mod * 45 % mod
	sum2 = 0
	add = 1
	ten = 0
	for i in range(len(sr) - 1, 0, -1):
		if sr[i] == sr[i - 1]:
			sum2 = (sum2 + int(sr[i]) * tenp[ten] * add % mod) % mod
		add = (add % mod + int(sr[i]) * tenp[ten] % mod) % mod
		ten += 1
	diff = 0
	power = 0
	for i in range(len(sr) - 1, 0, -1):
		if int(sr[i]) < int(sr[i - 1]):
			temp = (int(sr[i - 1]) - 1) * int(sr[i - 1]) // 2 % mod * tenp[power * 2] % mod
		elif int(sr[i]) > int(sr[i - 1]):
			temp = (int(sr[i - 1]) + 1) * int(sr[i - 1]) // 2 % mod * tenp[power * 2] % mod
		else:
			temp = 0
			temp = (temp % mod + (int(sr[i - 1]) - 1) * int(sr[i - 1]) // 2 % mod * tenp[power * 2] % mod) % mod
		diff = (diff % mod + temp % mod) % mod
		power += 1
	ans = (modDivide(n % mod * ((n + 1) % mod) % mod, 2, mod) - diff % mod) % mod
	ans = (ans - sum2 - sum) % mod
	return ans
t = int(input())
while t != 0:
	(nl, l) = map(int, input().split())
	(nr, r) = map(int, input().split())
	sumr = sumtill(r)
	suml = sumtill(l - 1)
	print((sumr - suml) % mod)
	t -= 1


from random import randint
mod = 10 ** 9 + 7

def solve(n, l, mod):
	v = n * pow(10, l, mod) % mod
	return (v - 1) * v // 2 % mod

def find_summ(s, mod):
	if len(s) == 1:
		return 0
	summ = solve(int(s[0]), len(s) - 2, mod)
	extra = 0
	for i in range(1, len(s)):
		if len(s) - i - 2 >= 0:
			t = (solve(int(s[i]), len(s) - i - 2, mod) + extra * int(s[i]) * pow(10, len(s) - i - 1, mod)) % mod
			if int(s[i - 1]) > int(s[i]):
				summ = (summ + t) % mod
			elif int(s[i - 1]) == int(s[i]):
				summ = (summ + t + int(s[i]) * pow(10, len(s) - i - 1, mod)) % mod
				extra = (extra + int(s[i]) * pow(10, len(s) - i - 1, mod)) % mod
			else:
				summ = (summ + t + int(s[i - 1]) * pow(10, 2 * (len(s) - i - 1), mod)) % mod
		elif int(s[i - 1]) > int(s[i]):
			summ = (summ + extra * int(s[i])) % mod
		else:
			summ = (summ + extra * int(s[i]) + int(s[i - 1])) % mod
	return summ

def final_summ(n, mod):
	t = int(n) % mod
	return (t * (t + 1) // 2 - find_summ(n, mod)) % mod
for _ in range(int(input())):
	(nl, l) = input().split()
	(nr, r) = input().split()
	l = str(int(l) - 1)
	print((final_summ(r, mod) - final_summ(l, mod)) % mod)


p10 = []
temp = 1
mod = 1000000007
minv = 500000004
for i in range(0, 300005):
	p10.append(temp)
	temp = temp * 10 % mod

def task(s, sl):
	s = '0' + s
	n = len(s)
	ans = 0
	for i in range(1, n - 1):
		a = int(s[i])
		b = n - i - 1
		temp = a * p10[b - 1]
		temp = temp * (temp - 1) * minv % mod
		ans = (ans + temp) % mod
		if a < int(s[i + 1]):
			temp = a * p10[(b - 1) * 2]
			ans = (ans + temp) % mod
		if a == int(s[i + 1]):
			temp = p10[b - 1]
			temp = a * temp + a * temp * sl[b - 2]
			ans = (ans + temp) % mod
	return ans

def task1(s, n):
	ll = []
	j = 1
	ll.append(int(s[n - 1]))
	for i in range(n - 2, -1, -1):
		temp = int(s[i]) * p10[j] % mod
		temp = (temp + ll[j - 1]) % mod
		ll.append(temp)
		j += 1
	ll = ll + [0]
	return ll
t = int(input())
for t0 in range(0, t):
	(nl, l) = input().split()
	(nr, r) = input().split()
	l = str(int(l) - 1)
	nl = len(l)
	nr = len(r)
	ll = task1(l, nl)
	rl = task1(r, nr)
	ans = (task(r, rl) - task(l, ll) + mod) % mod
	l = ll[nl - 1]
	r = rl[nr - 1]
	sum1 = (r * (r + 1) * minv % mod - l * (l + 1) * minv % mod + mod) % mod
	print((sum1 - ans + mod) % mod)


import math
MAX = 100000
M = 1000000007
sumF = {}

def f(str_n):
	exp = len(str_n) - 1
	temp = pow(10, exp % (M - 1), M)
	temp *= int(str_n[0])
	ans = []
	ans.append(temp % M)
	for i in range(1, len(str_n)):
		exp -= 1
		temp = ans[i - 1]
		if str_n[i] != str_n[i - 1]:
			temp = pow(10, exp % (M - 1), M)
			temp *= int(str_n[i])
			temp = (ans[i - 1] + temp % M) % M
		ans.append(temp)
	return ans

def calc(n):
	str_n = str(n)
	exp = len(str_n) - 1
	prev_digit = int(str_n[0])
	ans = sumF[prev_digit, exp]
	f_ans = f(str_n)
	for i in range(1, len(str_n)):
		curr_digit = int(str_n[i])
		exp -= 1
		ten_exp_mod = pow(10, exp % (M - 1), M)
		curr_f_val_mod = curr_digit * ten_exp_mod % M
		temp = 0
		if curr_digit > prev_digit and curr_digit > 0:
			temp = f_ans[i - 1] * curr_f_val_mod % M
			temp += sumF[curr_digit, exp]
			temp -= prev_digit * ten_exp_mod * ten_exp_mod % M
			temp %= M
		elif curr_digit <= prev_digit and curr_digit > 0:
			temp = f_ans[i - 1] * curr_f_val_mod % M
			temp += sumF[curr_digit, exp]
			temp %= M
		ans += temp
		ans %= M
		prev_digit = curr_digit
	ans += f_ans[len(str_n) - 1]
	return ans % M

def init():
	sumF[0, 0] = 0
	for i in range(1, 10):
		sumF[i, 0] = sumF[i - 1, 0] + i - 1
	sumF[1, 1] = 45
	k = 1
	ten_2k = 100
	ten_2k_2 = 1
	while k <= MAX:
		for i in range(2, 11):
			comp = (ten_2k - ten_2k_2) % M
			tup = (i, k)
			if i == 10:
				tup = (1, k + 1)
			sumF[tup] = i * sumF[1, k] + comp * (i * (i - 1)) // 2
			sumF[tup] %= M
		k += 1
		ten_2k = ten_2k * 100 % M
		ten_2k_2 = ten_2k_2 * 100 % M
init()
num_tests = int(input())
for t in range(num_tests):
	row1 = input().split()
	row2 = input().split()
	l = int(row1[1])
	r = int(row2[1])
	rval = calc(r)
	lval = calc(l - 1)
	ans = (rval - lval) % M
	ans = (ans + M) % M
	print(ans)


MOD = int(1000000000.0) + 7
MAX = int(300000.0) + 5
cnt = [1]
one = [0]
for i in range(1, MAX):
	cnt.append(cnt[-1] * 10 % MOD)
	one.append((one[-1] * 10 + 1) % MOD)

def get_val(l, n):
	last = None
	total = r = 0
	for i in range(n):
		curr = int(l[i])
		if curr:
			first_p = n - i - 1 << 1
			temp = curr * (curr - 1) >> 1
			if last and curr > last:
				temp -= last
			a = temp * cnt[first_p] % MOD
			if last and curr > last:
				temp += last
			second_p = first_p - 2
			b = c = 0
			if second_p >= 0:
				b = (curr * 45 - temp) * cnt[second_p] % MOD
				terms = n - i - 2
				third_p = second_p - terms - 1
				if terms >= 0 and third_p >= 0:
					c = one[terms] * cnt[third_p] % MOD
					c = c * 405 * curr % MOD
			r += (a + b + c) % MOD
			r += total * cnt[n - i - 1] * curr % MOD
		if curr != last:
			total += curr * cnt[n - i - 1] % MOD
		last = curr
	return r % MOD

def get_curr_val(l, n):
	x = i = 0
	while i < n:
		j = i
		x += int(l[j]) * cnt[n - j - 1]
		while i < n and l[i] == l[j]:
			i += 1
	return x % MOD
t = int(input())
for _ in range(t):
	(nl, l) = input().split()
	(nr, r) = input().split()
	(nl, nr) = map(int, (nl, nr))
	x = get_val(l, nl)
	y = get_val(r, nr)
	z = get_curr_val(r, nr)
	print((y - x + z) % MOD)


mod = 1000000007
exp = [1]
l = 1
for i in range(200008):
	l *= 10
	l %= mod
	exp.append(l)

def all(n):
	z = exp[n - 1]
	z *= z - 1
	return z // 2

def until(n, v):
	if n <= 0:
		return 0
	z = all(n)
	z *= v + 1
	zz = v * (v + 1) // 2
	zz *= exp[2 * n - 2]
	return z + zz

def num(s, st, en):
	if st > en:
		return 0
	return int(s[st:en + 1])

def f(s, st, en, arr):
	if st == en:
		return 0
	if ord(s[st]) == ord('0'):
		return 0
	sz = en - st + 1
	k = ord(s[st]) - ord('0')
	v = until(sz - 1, k - 1)
	if s[st] < s[st + 1]:
		v += k * exp[2 * sz - 4]
	elif s[st] == s[st + 1]:
		q = arr[en - st - 2]
		if st + 2 > en:
			q = 0
		v += k * exp[sz - 2] * (1 + q) % mod
	return v

def val(s):
	z = num(s, 0, len(s) - 1) % mod
	z *= z + 1
	z = z // 2
	a = []
	v = 0
	for i in range(len(s) - 1, -1, -1):
		v += exp[len(s) - 1 - i] * (ord(s[i]) - ord('0'))
		v %= mod
		a.append(v)
	for j in range(0, len(s)):
		z -= f(s, j, len(s) - 1, a)
	return z
t = int(input())
while t > 0:
	t -= 1
	s = input().split()[1]
	s = str(num(s, 0, len(s) - 1) - 1)
	ss = input().split()[1]
	z = val(s)
	zz = val(ss)
	print(((zz - z) % mod + mod) % mod)