Problem: Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not.

You are given a segment [L; R]. Count the number of classy integers x such that L ≤ x ≤ R.

Each testcase contains several segments, for each of them you are required to solve the problem separately.

Input

The first line contains a single integer T (1 ≤ T ≤ 10^4) — the number of segments in a testcase.

Each of the next T lines contains two integers L_i and R_i (1 ≤ L_i ≤ R_i ≤ 10^{18}).

Output

Print T lines — the i-th line should contain the number of classy integers on a segment [L_i; R_i].

Example

Input

4
1 1000
1024 1024
65536 65536
999999 1000001


Output

1000
1
0
2

Solution (in PYTHON):

Solution:
t = input()

dp = [0, 9, 90, 900]

for d in range(4, 20):
	ans = 9
	ans += 9 * (d-1) * 9
	ans += 9 * (d-1) * (d-2) * 9 * 9 / 2

	dp.append(ans)

def small(x):
	c = str(x)
	ans = int(c[0])
	ans += (int(c[0]) - 1) * (len(c) - 1) * 9
	ans += (int(c[0]) - 1) * (len(c)-1) * (len(c)-2) / 2 * 9 * 9
	
	for i in range(1, len(c)):
		if c[i] == '0':
			continue
		else:
			ans += int(c[i])
			ans += (len(c) - 1 - i) * 9
			break

	f = False
	for i in range(1, len(c)):
		if c[i] != '0':
			for j in range(i+1, len(c)):
				if c[j] != '0':
					f = True
					break

			if f:
				break

	for i in range(1, len(c)):
		if c[i] == '0':
			continue
		else:
			if not f:
				d = len(c) - i - 1
				ans += (int(c[i]) - 1) * d * 9
				ans += d * (d-1) /2 * 9 * 9
			else:
				for j in range(i+1, len(c)):
					if c[j] == '0':
						continue
					else:
						d = len(c) - i - 1
						ans += (int(c[i]) - 1) * d * 9
						ans += int(c[j])
						ans += (len(c) - j - 1) * 9
						ans += d * (d-1) /2 * 9 * 9
						break
			break

	return ans

for _ in range(t):
	l, r = map(int, raw_input().split())
	dl = len(str(l))
	dr = len(str(r))

		

	ans = 0

	for d in range(dl, dr):
		ans += dp[d]

	ans += small(r)
	ans -= small(l)

	if len([c for c in str(l) if c != '0']) <= 3:
		ans += 1

	print ans