You are given two integers $A$ and $B$, calculate the number of pairs $(a, b)$ such that $1 \le a \le A$, $1 \le b \le B$, and the equation $a \cdot b + a + b = conc(a, b)$ is true; $conc(a, b)$ is the concatenation of $a$ and $b$ (for example, $conc(12, 23) = 1223$, $conc(100, 11) = 10011$). $a$ and $b$ should not contain leading zeroes.


-----Input-----

The first line contains $t$ ($1 \le t \le 100$) — the number of test cases.

Each test case contains two integers $A$ and $B$ $(1 \le A, B \le 10^9)$.


-----Output-----

Print one integer — the number of pairs $(a, b)$ such that $1 \le a \le A$, $1 \le b \le B$, and the equation $a \cdot b + a + b = conc(a, b)$ is true.


-----Example-----
Input
3
1 11
4 2
191 31415926

Output
1
0
1337



-----Note-----

There is only one suitable pair in the first test case: $a = 1$, $b = 9$ ($1 + 9 + 1 \cdot 9 = 19$).

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
def nines(n):
	count = 0
	i = 1
	while n >= 10 ** i - 1:
		count += 1
		i += 1
	return count
numberofcases = int(input())
for _ in range(numberofcases):
	(x, y) = [int(t) for t in input().split()]
	print(x * nines(y))


import math

def inp(dtype=str, strip=True):
	s = input()
	res = [dtype(p) for p in s.split()]
	res = res[0] if len(res) == 1 and strip else res
	return res

def problem1():
	t = inp(int)
	for _ in range(t):
		(n, d) = inp(int)
		res = False
		sq = math.floor(math.sqrt(d))
		for x in range(max(sq - 1000, 0), min(sq + 1000, n)):
			if x + math.ceil(d / (x + 1)) <= n:
				res = True
				break
		if res:
			print('YES')
		else:
			print('NO')

def problem2():
	t = inp(int)
	for _ in range(t):
		(A, B) = inp(int)
		res = 0
		len_b = 1
		while 10 ** len_b - 1 <= B:
			res += A
			len_b += 1
		print(res)

def problem3():
	pass

def problem4():
	pass

def problem5():
	pass

def problem6():
	pass
problem2()


import math
n = int(input())
for _ in range(n):
	(a, b) = input().split()
	if int(b) != pow(10, len(b)) - 1:
		b = min(int(b), pow(10, len(b) - 1) - 1)
	if b == 0:
		print('0')
	else:
		temp = int(a) * len(str(b))
		print(temp)


t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	cntgood = 0
	for c in range(1, 20):
		if int('9' * c) <= b:
			cntgood += 1
		else:
			break
	print(a * cntgood)


t = int(input())
for i in range(t):
	ab = str(input()).split(' ')
	A = int(ab[0])
	B = int(ab[1])
	c = len(str(B))
	if B != 10 ** c - 1:
		print(A * (len(str(B)) - 1))
	else:
		print(A * len(str(B)))


import math
t = int(input())
for _ in range(t):
	x = input().split()
	A = int(x[0])
	B = x[1]
	l = len(B)
	s = 0
	if l >= 2:
		s += A * (l - 1)
	if 10 ** l - 1 <= int(B):
		s += A
	print(s)


t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	print(a * (len(str(b + 1)) - 1))


from math import floor, log10
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	result = a * floor(log10(b + 1))
	print(result)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	x = 0
	ans = 0
	for i in range(b):
		x = x * 10 + 9
		if b >= x:
			ans += a
		else:
			break
	print(ans)


t = int(input())
while t:
	(a, b) = map(int, input().split())
	cnt = 0
	print(a * (len(str(b + 1)) - 1))
	t -= 1


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if b < int('9' * len(str(b))):
		print((len(str(b)) - 1) * a)
	else:
		print(len(str(b)) * a)


n = int(input())
while n > 0:
	(a, b) = map(int, input().split())
	b = b + 1
	ans = a * (len(str(b)) - 1)
	print(ans)
	n = n - 1


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(a * int(math.log(b + 1, 10)))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = b
	b = len(str(b))
	if c != int('9' * b):
		b -= 1
	print(b * a)


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	nb = 0
	now = 10
	for i in range(10):
		if B >= now - 1:
			nb += 1
		now *= 10
	print(A * nb)


t = int(input())
for e in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	l = [a, b]
	k = max(l)
	k = str(b + 1)
	le = len(k) - 1
	print(a * le)


def digits(n):
	i = 0
	while n > 0:
		n //= 10
		i += 1
	return i

def pair_count(a, b):
	z = digits(b)
	if b == 10 ** z - 1:
		z += 1
	return (z - 1) * a

def main():
	t = int(input())
	a = []
	b = []
	for _ in range(t):
		(at, bt) = map(int, input().split())
		a += [at]
		b += [bt]
	for i in range(t):
		print(pair_count(a[i], b[i]))
main()


for _ in range(int(input())):
	(a, b) = list((int(x) for x in input().split()))
	print(a * (len(str(b + 1)) - 1))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ret = 0
	cur = 9
	while cur <= b:
		ret += a
		cur = cur * 10 + 9
	print(ret)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	k = str(b)
	if int('9' * len(k)) == b:
		print(len(k) * a)
	else:
		print((len(k) - 1) * a)


import sys
import math
num = int(input())
for i in range(num):
	(a, b) = [int(x) for x in input().split()]
	count = 0
	nine = 9
	while nine <= b:
		count += 1
		nine = nine * 10
		nine += 9
	print(count * a)


from sys import stdin

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(a, b) = [int(x) for x in inp().split()]
	ar = [9]
	counter = 0
	while True:
		if int(ar[0]) <= b:
			counter += 1
		else:
			break
		ar[0] = int(str(ar[0]) + '9')
	print(a * counter)


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	n = a * (len(str(b + 1)) - 1)
	print(n)


n = int(input())
for i in range(0, n):
	a = list(map(int, input().split()))
	a[1] += 1
	a[1] = str(a[1])
	print(a[0] * (len(a[1]) - 1))


for i in [0] * int(input()):
	(a, b) = map(int, input().split())
	print(a * (len(str(b + 1)) - 1))


for case in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	k = ''
	while int(k + '9') <= b:
		k += '9'
	print(a * len(k))


def numberOfSymbols(x):
	count = 0
	while x >= 1:
		x //= 10
		count += 1
	return count
t = int(input())
for i in range(t):
	a = [int(x) for x in input().split()]
	print(a[0] * (numberOfSymbols(a[1] + 1) - 1))


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
for _ in range(inn()):
	(a, b) = svalue()
	res = len(b)
	if int(b) < int('9' * res):
		res -= 1
	print(int(a) * res)


tc = int(input())
for i in range(tc):
	(a, b) = input().split()
	x = int(a)
	y = int(b)
	s2 = len(str(y))
	if int('9' * s2) > y:
		print((s2 - 1) * x)
	else:
		print(s2 * x)


t = int(input())
for _ in range(t):
	(A, B) = list(map(int, input().split()))
	ans = 0
	nines = 9
	while nines <= B:
		ans += A
		nines = nines * 10 + 9
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	x = 9
	ans = 0
	while x <= b:
		ans += a
		x = x * 10 + 9
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	i = 0
	x = 9
	while x <= b:
		x *= 10
		x += 9
		i += 1
	print(a * i)


from math import ceil, log10

def conc(a, b):
	return a * 10 ** ceil(log10(b)) + b
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(a * (len(str(b + 1)) - 1))


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	num = 9
	ans = 0
	while num <= B:
		ans += A
		num = int(str(num) + '9')
	print(ans)


n = int(input())
for test in range(n):
	(a, b) = map(int, input().split())
	print(a * (len(str(b + 1)) - 1))


for i in range(int(input())):
	arr = [int(i) for i in input().split()]
	(a, b) = (arr[0], arr[1])
	l = len(str(b))
	no = l
	for j in str(b):
		if int(j) != 9:
			no = l - 1
	print(a * no)


import math
t = int(input())
for T in range(t):
	(a, b) = [int(x) for x in input().split()]
	if b < 9:
		print(0)
		continue
	i = 9
	count = 0
	while i <= b:
		count += 1
		i = i * 10 + 9
	j = count
	print(j * a)


for test in range(int(input())):
	(A, B) = map(int, input().split())
	ans = A * (len(str(B)) - 1)
	if B == int('9' * len(str(B))):
		ans += A
	print(ans)


for i in range(int(input())):
	(a, b) = input().split()
	p = len(a)
	q = len(b)
	if b == q * '9':
		w = q
	else:
		w = q - 1
	print(w * int(a))


t = int(input())
for i in range(t):
	c = 0
	(A, B) = map(int, input().split())
	s = 9
	c = 0
	while s <= B:
		s = int(str(s) + str(9))
		c = c + 1
	print(c * A)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = 0
	m = 9
	while m <= b:
		c += a
		m = 10 * m + 9
	print(c)


t = int(input())
for i in range(t):
	(A, B) = tuple([int(x) for x in input().split(' ')])
	b = 0
	n = 0
	for j in range(len(str(B))):
		b = b * 10 + 9
		if b <= B:
			n += 1
	print(A * n)


for a in range(int(input())):
	(c, v) = map(int, input().split())
	print(c * (len(str(v + 1)) - 1))


t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	if B < 9:
		print(0)
	else:
		cnt = 1
		s = '9'
		while int(s) <= B:
			s += '9'
			cnt += 1
		cnt -= 1
		print(A * cnt)


for _ in range(int(input())):
	(A, B) = list(map(int, input().split()))
	res = 0
	seed = 9
	while seed <= B:
		res += A
		seed = seed * 10 + 9
	print(res)


from math import log
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(a * (len(str(b + 1)) - 1))


exec(int(input()) * "a,b=input().split();print(int(a)*(len(b)-1+({*b}=={'9'})));")


def f(l):
	(A, B) = l
	i = 0
	mx = 9
	while B >= mx:
		mx = mx * 10 + 9
		i += 1
	return i * A
q = int(input())
for _ in range(q):
	l = list(map(int, input().split()))
	print(f(l))


for i in range(int(input())):
	(A, B) = map(int, input().split())
	d = 9
	cnt = 0
	while d <= B:
		cnt += 1
		d = d * 10 + 9
	print(A * cnt)


for cases in range(int(input())):
	(a, b) = map(int, input().split())
	print(a * (len(str(b + 1)) - 1))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(a, b) = map(int, sys.stdin.readline().split())
	strb = str(b)
	z = True
	for i in range(len(strb)):
		if strb[i] != '9':
			z = False
	if z:
		print(a * len(strb))
	else:
		print(a * (len(strb) - 1))


for i in range(int(input())):
	(A, B) = map(int, input().split())
	(a, b) = (B + 1, 0)
	while a != 0:
		b += 1
		a = a // 10
	print(A * (b - 1))


z = ['9' * i for i in range(1, 10)]
for i in range(len(z)):
	z[i] = int(z[i])
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	count = 0
	for i in z:
		if i <= b:
			count += 1
	print(a * count)


t = int(input())
while t:
	(n, m) = map(str, input().split())
	print(int(n) * (len(m) if m == '9' * len(m) else len(m) - 1))
	t -= 1


t = int(input())
while t > 0:
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	c = 9
	ans = 0
	while c <= b:
		ans += a
		c = 10 * c + 9
	print(ans)
	t -= 1


from math import *
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = 0
	b += 1
	while b:
		b = b // 10
		c += 1
	print(a * (c - 1))


a = '9'
l = []
for i in range(20):
	l.append(int(a))
	a += '9'
from math import ceil
t = int(input())
while t:
	(a, b) = map(int, input().split())
	cou = 0
	for i in l:
		if i <= b:
			cou += 1
		else:
			break
	print(cou * a)
	t -= 1


t = int(input())
for i in range(t):
	kol = 0
	kolb = 0
	(A, B) = map(int, input().split())
	if B < 9:
		print(0)
	else:
		for x in range(1, 10):
			b = 10 ** x - 1
			if b <= B:
				kolb += 1
		kol = kolb * A
		print(kol)


for _ in [0] * int(input()):
	(a, b) = [int(x) for x in input().split()]
	print(a * (len(str(b + 1)) - 1))


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
t = rint()
for _ in range(t):
	(a, b) = rints()
	c = 0
	for i in range(1, 20):
		if 10 ** i - 1 <= b:
			c += 1
	print(c * a)


t = int(input())
i = 0
while i < t:
	(a, b) = map(int, input().split())
	b = b + 1
	d = 0
	ans = 0
	while b != 0:
		d += 1
		b //= 10
	ans = a * (d - 1)
	print(ans)
	i += 1


t = int(input())
for _ in range(t):
	(A, B) = list(map(int, input().split()))
	b = -1
	B += 1
	while B:
		b += 1
		B //= 10
	print(A * b)


x = int(input())
i = 0
while i < x:
	i = i + 1
	(a, b) = map(int, input().split())
	length = len(str(b))
	if b != 10 ** length - 1:
		length = length - 1
	print(a * length)


result = []
for m in range(int(input())):
	(num1, num2) = map(int, input().split())
	tem_result = 0
	num_len = len(str(num2)) - 1
	tem_cal = 10 ** (num_len + 1)
	tem_cal -= 1
	if num2 == tem_cal:
		num_len += 1
	tem_result = num1 * num_len
	result.append(tem_result)
for m in result:
	print(m)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	nine = 9
	cnt = 0
	while nine <= b:
		cnt += 1
		nine += 10 ** cnt * 9
	print(cnt * a)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	b += 1
	ans = a * int(len(str(b)) - 1)
	print(ans)


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
mod = 10 ** 9 + 7

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def solve():
	(a, b) = num_input()
	print(a * (len(str(b + 1)) - 1))
t = int(input())
for _ in range(t):
	solve()


from math import log10
T = int(input())
for t in range(T):
	(A, B) = map(int, input().split())
	print(A * int(log10(B + 1)))


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	t = inin()
	for _ in range(t):
		(a, b) = cin()
		j = 0
		x = 0
		while j <= b:
			if j * 10 + 9 <= b:
				j = j * 10 + 9
				x += 1
			else:
				break
		print(a * x)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


t = int(input())
for i in range(t):
	(a, b) = [i for i in input().split()]
	toadd = 0
	cmpr = '9' * len(b)
	if int(b) == int(cmpr):
		toadd = 1
	print(int(a) * (len(b) - 1 + toadd))


def f(x):
	res = 0
	c = 0
	while 1:
		if res * 10 + 9 <= x:
			res *= 10
			res += 9
			c += 1
		else:
			break
	return c
for n in range(int(input())):
	(a, b) = map(int, input().split())
	print(a * f(b))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	y += 1
	c = 0
	while y > 0:
		y //= 10
		c += 1
	print(x * (c - 1))


n = int(input())
for i in range(n):
	s = [int(i) for i in input().split()]
	a = s[0]
	b = s[1]
	s = 9
	mn = 0
	while b // s != 0:
		if b // s >= 0:
			s = s * 10 + 9
			mn += 1
	print(mn * a)


def find():
	t = int(input())
	for __ in range(t):
		(a, b) = map(int, input().split())
		sum = 0
		count = 0
		while sum * 10 + 9 <= b:
			count += 1
			sum = sum * 10 + 9
		print(a * count)
find()


for ii in range(int(input())):
	(a, b) = map(int, input().split())
	x = 9
	while True:
		if x > b:
			print(a * (len(str(x)) - 1))
			break
		x = x * 10 + 9


def binarySearch(arr, x):
	l = 0
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
from math import *
for i in range(int(input())):
	(n, m) = map(int, input().split())
	print(n * (len(str(m + 1)) - 1))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	print(x * (len(str(y + 1)) - 1))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = 9
	ans = 0
	while b >= s:
		ans += a
		s = s * 10 + 9
	print(ans)


n = int(input())
while n:
	n -= 1
	(u, v) = map(str, input().split())
	o = len(u)
	p = len(v)
	if len(set(list(v))) == 1 and v[0] == '9':
		print(int(u) * p)
	else:
		print(int(u) * (p - 1))


for i in range(0, int(input())):
	(a, b) = map(int, input().split())
	n = len(str(b))
	if b != 10 ** n - 1:
		n -= 1
	print(n * a)


t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	cnt = 0
	b += 1
	b //= 10
	while b:
		cnt += 1
		b //= 10
	ans = cnt * a
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b < 9:
		print(0)
		continue
	else:
		b = str(b)
		s = list(set(b))
		if len(s) == 1 and s[0] == '9':
			b = len(b)
		else:
			b = len(b) - 1
		print(a * b)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(a, b) = map(int, sys.stdin.readline().split(' '))
	tot = 0
	for i in range(1, 11):
		v = pow(10, i)
		v -= 1
		if b >= v:
			tot += 1
	print(a * tot)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


def fun():
	(a, b) = map(int, input().split())
	l = len(str(b + 1))
	return a * (l - 1)
t = int(input())
for i in range(t):
	print(fun())


t = int(input())
for _ in range(t):
	[a, b] = list(map(int, input().split()))
	c = str(b)
	d = len(c)
	if b != 10 ** d - 1:
		d -= 1
	ans = a * d
	print(ans)


def countDigit(n):
	if n == 0:
		return 0
	return 1 + countDigit(n // 10)
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a < 9 and b < 9:
		print(0)
	else:
		d = countDigit(b)
		ans = '9' * d
		if b < int(ans):
			d = d - 1
		print(a * d)


import math
t = int(input())
for p in range(t):
	numeros = list(map(int, input().split(' ')))
	a = numeros[0]
	b = numeros[1]
	tamanhoB = len(str(b))
	buffer = ''
	for k in range(tamanhoB):
		buffer += '9'
	if int(buffer) > b:
		cont = tamanhoB - 1
	else:
		cont = tamanhoB
	print(a * cont)


import math
tc = int(input())
for _ in range(tc):
	(a, b) = [int(x) for x in input().split()]
	c = 0
	e = 10
	i = 0
	while True:
		i += 1
		e = 10 ** i - 1
		if e <= b:
			c += a
		else:
			break
	print(c)


def call(n):
	c = 0
	t = 0
	while n > 0:
		k = n % 10
		n = n // 10
		if k == 9:
			t += 1
		c += 1
	if c == t:
		return c
	else:
		return c - 1
for i in range(int(input())):
	(a, b) = map(int, input().split())
	ans = call(b)
	print(ans * a)


def main():
	(a, b) = map(int, input().split())
	ans = a * (len(str(b + 1)) - 1)
	print(ans)
t = int(input())
for i in range(t):
	main()


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	l1 = []
	x = str(n)
	y = str(d)
	c1 = len(x) - 1
	c2 = len(y) - 1
	if d < 10:
		if d == 9:
			print(n)
		else:
			print(0)
	elif c1 > c2:
		if d == 10 ** (c2 + 1) - 1:
			c2 += 1
		print(n * c2)
	else:
		if d == 10 ** (c2 + 1) - 1:
			c2 += 1
		print(n * c2)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	ans = 0
	for i in range(1, 10):
		a = '9' * i
		if y >= int(a):
			ans += 1
	print(ans * x)


t = int(input())
for _ in range(t):
	(a, b) = input().split(' ')
	aset = set(b)
	if int(list(aset)[0]) == 9 and len(aset) == 1:
		print(len(b) * int(a))
	else:
		print((len(b) - 1) * int(a))


from math import log10
for _ in range(int(input())):
	(A, B) = map(int, input().split())
	print(int(log10(max(1, B + 1))) * A)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if b < 9:
		print(0)
	elif set(str(b)) == set('9'):
		print(len(str(b)) * a)
	else:
		print((len(str(b)) - 1) * a)


from sys import stdin
import math
input = stdin.buffer.readline

def solve(a, b):
	cnt = len(str(b))
	if (b + 1) % 10 ** cnt != 0:
		cnt -= 1
	return a * cnt

def main():
	n = int(input())
	for i in range(n):
		(a, b) = [int(i) for i in input().split()]
		print(solve(a, b))
main()


from math import floor, log
for _ in range(int(input())):
	(A, B) = map(int, input().split())
	print(A * (len(str(B + 1)) - 1))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	i = '9'
	while int(i) <= b:
		i += '9'
	print((len(i) - 1) * a)


for t in range(int(input())):
	(a, b) = list(map(int, input().split()))
	print(a * (len(str(b + 1)) - 1))


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	counter = 0
	x = 9
	while x <= B:
		counter += 1
		x = x * 10 + 9
	print(A * counter)


from math import log10
for _ in range(int(input())):
	(A, B) = (int(i) for i in input().split())
	print(A * int(log10(B + 1)))


def fun(a, b):
	ans = 0
	k = 1
	while 10 ** k - 1 <= b:
		ans += a
		k += 1
	return ans
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(fun(a, b))


import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def dijkstra(start, distance, path, n):
	visited = [False for _ in range(n)]
	distance[start] = 0
	for i in range(n):
		v = -1
		for j in range(n):
			if not visited[v] and (v == -1 or distance[j] < distance[v]):
				v = j
		if distance[v] == math.inf:
			break
		visited[v] = True
		for edge in adj[v]:
			destination = edge[0]
			weight = edge[1]
			if distance[v] + weight < distance[destination]:
				distance[destination] = distance[v] + weight
				path[destination] = v

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		for _ in range(inp()):
			(a, b) = invr()
			s = len(str(b))
			ans = a * (s - 1)
			if set(str(b)) == {'9'}:
				ans += a
			print(ans)
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from math import ceil
T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	lb = len(str(b))
	if b < 10 ** lb - 1:
		lb -= 1
	print(lb * a)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if b < 9:
		print(0)
		continue
	k = 0
	b += 1
	while b:
		b //= 10
		k += 1
	print(a * (k - 1))


t = int(input())

def conc(s1, s2):
	a = str(s1)
	b = str(s2)
	return int(a + b)
count = 0
for i in range(t):
	arr = list(map(float, input().split()))
	(x, y) = (arr[0], arr[1])
	b = []
	for j in range(len(str(y)), 0, -1):
		if 10 ** j - 1 <= y:
			b.append(10 ** j - 1)
	count = x * len(b)
	print(int(count))


import math
t = int(input())
while t != 0:
	t = t - 1
	(As, Bs) = [str(x) for x in input().split()]
	lenb = len(Bs)
	count = 0
	B = int(Bs)
	for i in range(1, lenb + 1):
		rhs = math.pow(10, i)
		temp = rhs - 1
		b = temp
		if b >= 1 and b <= B and (len(str(int(b))) == i):
			count = count + 1
	count = count * int(As)
	print(count)


def arr_inp():
	return [int(x) for x in stdin.readline().split()]
from sys import stdin
for i in range(int(input())):
	(a, b) = arr_inp()
	l = len(str(b))
	if str(b).count('9') != l:
		l -= 1
	print(a * l)


from sys import stdin

def rl():
	return [int(w) for w in stdin.readline().split()]

def check(n, d):
	tmp = str(d)
	k = len(tmp)
	k = k - 1
	if d >= pow(10, k + 1) - 1:
		k += 1
	return n * k
test = int(stdin.readline())
while test:
	(n, d) = rl()
	print(check(n, d))
	test -= 1


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	(result, nine) = (0, 9)
	while nine <= b:
		result += 1
		nine = nine * 10 + 9
	print(a * result)


nt = int(input())
while nt != 0:
	(a, b) = map(int, input().split())
	b = str(b)
	if b.count('9') != len(b):
		print((len(b) - 1) * a)
	else:
		print(len(b) * a)
	nt -= 1


t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	ref = len(str(b))
	if int('9' * ref) <= b:
		le = ref
	else:
		le = ref - 1
	print(a * le)


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	k = len(str(B))
	count = 0
	for i in range(1, k + 1):
		c = 10 ** i - 1
		if c <= B:
			count += A
	print(count)


from sys import stdin as cin, stdout as cout
get = cin.readline
put = cout.write
end = cout.flush

def fun(B):
	b = 9
	cnt = 0
	while b <= B:
		b = b * 10 + 9
		cnt += 1
	return cnt
tc = int(get())
while tc != 0:
	tc -= 1
	(a, b) = map(int, get().split())
	put(str(fun(b) * a))
	put('\n')
end()


t = int(input().strip())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(a * (len(str(b + 1)) - 1))


for _ in range(int(input())):
	(a, b) = input().split()
	if '9' * len(b) == b:
		print(int(a) * len(b))
	else:
		print(int(a) * (len(b) - 1))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	m = str(m)
	flag = 1
	for i in m:
		if i != '9':
			flag = 0
			break
	if flag == 0:
		dig = len(m) - 1
	else:
		dig = len(m)
	print(dig * n)


t = int(input())
alpha = []
for i in range(t):
	(A, B) = map(int, input().split())
	n = 9
	cnt = 0
	while n <= B:
		cnt += 1
		n = n * 10 + 9
	alpha.append(int(A * cnt))
for i in range(len(alpha)):
	print(alpha[i])


def solve(A, B):
	cnt = 0
	b = 9
	while b <= B:
		cnt += A
		b = 10 * b + 9
	return cnt

def main():
	t = int(input())
	for _ in range(t):
		print(solve(*map(int, input().split())))
main()


t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	len1 = len(str(b))
	if 10 ** len1 == b + 1:
		print(a * len1)
	else:
		print(a * (len1 - 1))


import sys
nines = [int('9' * i) for i in range(1, 20)]
t = int(input())
for _ in range(t):
	(alim, blim) = map(int, input().split(' '))
	res = 0
	for i in nines:
		if i <= blim:
			res += 1
	print(res * alim)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = math.floor(math.log(b + 1, 10))
	print(c * a)


def gen(n):
	s = ''
	for i in range(n):
		s += '1'
	val = int(s)
	return 9 * val
for _ in range(int(input())):
	l = list(map(int, input().split()))
	A = l[0]
	B = l[1]
	count_digs = 0
	i = 0
	while 1:
		if B // pow(10, i) == 0:
			break
		count_digs += 1
		i += 1
	count_b = count_digs
	if gen(count_digs) > B:
		count_b -= 1
	print(count_b * A)


t = int(input())
for a0 in range(t):
	l = input().split(' ')
	a = l[0]
	b = l[1]
	ans = len(b) - 1
	if b == '9' * len(b):
		ans += 1
	print(int(a) * ans)


t = int(input())
for i in range(t):
	temp = list(input().split())
	A = int(temp[0])
	B = int(temp[1])
	cnt = 0
	f = B + 1
	while f > 0:
		f = f // 10
		cnt += 1
	print(cnt * A - A)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(x, k, c) = (b, 0, 0)
	while x > 0:
		if x % 10 == 9:
			k += 1
		c += 1
		x = x // 10
	if k == c:
		print(a * k)
	else:
		print(a * (c - 1))


import math
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	print(n * (len(str(m + 1)) - 1))


n = eval(input())
for i in range(n):
	(A, B) = map(int, input().split())
	if B < 9:
		print(0)
	elif 9 <= B < 99:
		print(A)
	elif 99 <= B < 999:
		print(A * 2)
	elif 999 <= B < 9999:
		print(A * 3)
	elif 9999 <= B < 99999:
		print(A * 4)
	elif 99999 <= B < 999999:
		print(A * 5)
	elif 999999 <= B < 9999999:
		print(A * 6)
	elif 9999999 <= B < 99999999:
		print(A * 7)
	elif 99999999 <= B < 999999999:
		print(A * 8)
	else:
		print(A * 9)


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

def MI():
	return map(int, input().split())

def S():
	return input()

def MS():
	return map(str, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def input():
	return sys.stdin.readline().rstrip()

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False

def main():
	t = I()
	A = [0] * t
	B = [0] * t
	for i in range(t):
		(A[i], B[i]) = MI()
	for i in range(t):
		c = 0
		cur = 9
		while cur <= B[i]:
			c += 1
			cur *= 10
			cur += 9
		print(A[i] * c)
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	count = 0
	num = 9
	temp = 9
	while temp <= b:
		count += 1
		temp = temp * 10 + num
	print(a * count)


for _ in range(int(input())):
	(a, b) = input().split()
	d = len(b)
	a = int(a)
	b = int(b)
	if b == 10 ** d - 1:
		print(a * d)
	else:
		print(a * (d - 1))


t = int(input())
ans = []
for _ in range(t):
	(a, b) = map(int, input().split())
	len_b = len(str(b))
	if (b + 1) % 10 ** len_b != 0:
		len_b -= 1
	p = a * len_b
	ans.append(p)
for i in ans:
	print(i)


t = int(input())
for _ in range(t):
	(A, B) = [int(x) for x in input().split()]
	lenB = len(str(B))
	if int('9' * lenB) != B:
		lenB -= 1
	print(A * lenB)


for _ in range(int(input().strip())):
	(a, b) = [int(__) for __ in input().strip().split()]
	bb = set(str(b))
	if len(bb) == 1 and '9' in bb:
		print(a * len(str(b)))
	else:
		print(a * (len(str(b)) - 1))


t = int(input())
for i in range(0, t):
	f = 0
	(a, b) = list(map(int, input().split()))
	c = str(b)
	p = []
	d = '9'
	while len(d) <= len(c):
		p.append(d)
		d = d + '9'
	if b < 9:
		p = []
		p.append('0')
	if int(p[len(p) - 1]) > b:
		p = p[0:len(p) - 1]
	if b < 9:
		print('0')
	else:
		print(a * len(p[len(p) - 1]))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	counter = 0
	for k in range(1, 10):
		b = 10 ** k - 1
		if b <= m:
			counter += n
	print(counter)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	cnt = 0
	mul = 9
	while mul <= b:
		cnt += 1
		mul = mul * 10 + 9
	print(cnt * a)


import math
t = int(input())

def go():
	(a, b) = map(int, input().split())
	bb = 0
	while 10 ** bb - 1 <= b:
		bb += 1
	print(a * (bb - 1))

def conc(aa, bb):
	return aa * 10 ** int(math.log10(bb) + 1) + bb
for _ in range(t):
	go()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	n = 1
	c = 0
	while 10 ** n <= b + 1:
		c += 1
		n += 1
	print(c * a)


t = int(input())
for q in range(t):
	z = input()
	z = z.split(' ')
	A = int(z[0])
	B = z[1]
	C = ''
	for i in range(len(B)):
		C += '9'
	mult = len(B) - 1
	if B == C:
		mult = len(B)
	count = A * mult
	print(count)


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, groupby
import sys
import bisect
import string
import math
import time
import random

def S_():
	return input()

def LS():
	return [i for i in input().split()]

def I():
	return int(input())

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def GI(V, E, Directed=False, index=0):
	org_inp = []
	g = [[] for i in range(n)]
	for i in range(E):
		inp = LI()
		org_inp.append(inp)
		if index == 0:
			inp[0] -= 1
			inp[1] -= 1
		if len(inp) == 2:
			(a, b) = inp
			g[a].append(b)
			if not Directed:
				g[b].append(a)
		elif len(inp) == 3:
			(a, b, c) = inp
			aa = (inp[0], inp[2])
			bb = (inp[1], inp[2])
			g[a].append(bb)
			if not Directed:
				g[b].append(aa)
	return (g, org_inp)

def bit_combination(k, n=2):
	rt = []
	for tb in range(n ** k):
		s = [tb // n ** bt % n for bt in range(k)]
		rt += [s]
	return rt

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10 ** 5)
input = lambda : sys.stdin.readline().rstrip()

def ran_input():
	import random
	n = random.randint(4, 16)
	(rmin, rmax) = (1, 10)
	a = [random.randint(rmin, rmax) for _ in range(n)]
	return (n, a)

class Comb:

	def __init__(self, n, mo=10 ** 9 + 7):
		self.fac = [0] * (n + 1)
		self.inv = [1] * (n + 1)
		self.fac[0] = 1
		self.fact(n)
		for i in range(1, n + 1):
			self.fac[i] = i * self.fac[i - 1] % mo
			self.inv[n] *= i
			self.inv[n] %= mo
		self.inv[n] = pow(self.inv[n], mo - 2, mo)
		for i in range(1, n):
			self.inv[n - i] = self.inv[n - i + 1] * (n - i + 1) % mo
		return

	def fact(self, n):
		return self.fac[n]

	def invf(self, n):
		return self.inv[n]

	def comb(self, x, y):
		if y < 0 or y > x:
			return 0
		return self.fac[x] * self.inv[x - y] * self.inv[y] % mo
show_flg = False
show_flg = True
ans = 0
t = I()
for i in range(1, 10 ** 5):
	if i + 1 == 10 ** (int(math.log(i, 10)) + 1):
		0
for _ in range(t):
	(a, b) = LI()
	n = 0
	for d in range(1, 10):
		if 10 ** d - 1 <= b:
			n += 1
	ans = a * n
	print(ans)


import math
for t in range(int(input())):
	(A, B) = list(map(int, input().split()))
	b1 = len(str(B))
	if B == int('9' * b1):
		ans = A * b1
	else:
		ans = A * (b1 - 1)
	print(ans)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(A, B) = [int(x) for x in input().split()]
		x = len(str(B)) - 1
		for b in str(B):
			if b != '9':
				break
		else:
			x += 1
		print(A * x)
main()


t = int(input())
l2 = []
for i in range(t):
	(n, d) = map(int, input().split())
	c = 0
	if d == 0:
		l2.append(0)
	c1 = d
	while d != 0:
		c += 1
		d = int(d / 10)
	if 10 ** c - 1 == c1:
		l2.append(c * n)
	else:
		l2.append((c - 1) * n)
for k in range(t):
	print(l2[k])


t = int(input(''))
for i in range(t):
	a = list(map(int, input().split()))
	n = a[0]
	m = a[1]
	p = 0
	j = m
	while m > 0:
		p += 1
		m = m // 10
	if j == 10 ** p - 1:
		print(n * p)
	else:
		print(n * (p - 1))


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		(A, B) = map(int, input().split())
		n = 0
		for i in range(1, len(str(B)) + 1):
			b = int('9' * i)
			if b <= B:
				n += 1
		ans = A * n
		print(ans)
main()


def checker(a, b):
	n = len(str(b)) - 1
	if b == int((n + 1) * '9'):
		n += 1
	return a * n
for _ in range(int(input())):
	(A, B) = [int(i) for i in input().split()]
	print(checker(A, B))


a = int(input())
for i in range(a):
	m = 9
	(x, y) = map(int, input().split())
	count = 0
	while m <= y:
		m = int(str(m) + '9')
		count += 1
	print(x * count)


t = int(input())
for _ in range(t):
	(a, b) = input().split()
	l = list(set(b))
	if l[0] == '9' and len(l) == 1:
		c = len(str(b))
	else:
		c = len(str(b)) - 1
	print(int(a) * c)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	n = 0
	num = '9'
	for i in range(9):
		num = '9' + i * '9'
		num = int(num)
		if num <= b:
			n += 1
		else:
			break
	res = a * n
	print(res)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	sum = 0
	r = 9
	while r <= b:
		sum = sum + 1
		r = r * 10 + 9
	print(sum * a)


import math
testCases = int(input())
for _ in range(testCases):
	(A, B) = map(int, input().split())
	count = 0
	start = 9
	addBy = 9
	while start <= B:
		count += 1
		start += addBy * 10
		addBy *= 10
	print(A * count)


def num_9(x):
	d = len(str(x))
	if len(str(x + 1)) < d + 1:
		d -= 1
	return d

def solve(A, B):
	numB = num_9(B)
	return numB * A
T = int(input())
for case in range(T):
	(A, B) = [int(x) for x in input().split()]
	print(solve(A, B))


l = []
l.append(9)
l.append(99)
l.append(999)
l.append(9999)
l.append(99999)
l.append(999999)
l.append(9999999)
l.append(99999999)
l.append(999999999)
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	k = 0
	for i in range(len(l)):
		if b >= l[i]:
			k += 1
	print(a * k)


t = int(input())
for eee in range(t):
	(a, b) = map(int, input().split())
	p = 9
	k = 0
	while p <= b:
		k += 1
		p = p * 10 + 9
	print(a * k)


test = int(input())
for z in range(test):
	(a, b) = map(int, input().split())
	ans = 0
	current = 9
	while current <= b:
		if current + 1 == 10 ** len(str(current)):
			ans += a
		current = current * 10 + 9
	print(ans)


tests = input()
tests = int(tests)
for p in range(tests):
	x = input().split(' ')
	a = x[0]
	b = x[1]
	print(int(a) * (len(str(int(b) + 1)) - 1))


for _ in range(int(input())):
	(a, b) = input().split()
	n = len(b)
	count = int(a) * (n - 1)
	if 10 ** n - 1 <= int(b):
		print(count + int(a))
	else:
		print(count)


def main():
	t = int(input())
	for _ in range(t):
		(A, B) = map(int, input().split())
		i = 0
		k = 1
		while k - 1 <= B:
			i += 1
			k *= 10
		i -= 1
		print(A * i)
	return
main()


import math
t = int(input())
for _ in range(t):
	s = input().split()
	A = int(s[0])
	B = int(s[1])
	if B < 9:
		print(0)
	else:
		zz = A * (len(str(B)) - 1)
		nn = 0
		while B > 0:
			if B % 10 != 9:
				nn = 1
				break
			B //= 10
		if nn == 0:
			zz += A
		print(zz)


import math as m
for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	ans = a * int(m.log10(b + 1))
	print(ans)


import math

def main():
	t = int(input())
	while t > 0:
		(A, B) = [int(x) for x in input().split(' ')]
		t -= 1
		x = int(math.log10(B) + 1)
		ans = 0
		for i in range(1, x + 1, 1):
			b = math.pow(10, i) - 1
			if b > B:
				break
			ans += A
		print(ans)
main()


for _ in range(int(input())):
	(n, m) = input().split()
	x = '9'
	f = True
	for i in m:
		if i != x:
			f = False
			break
	if f:
		print(int(n) * len(m))
	else:
		print(int(n) * (len(m) - 1))


t = int(input())
while t:
	t -= 1
	ans = 0
	(a, b) = map(int, input().split())
	k = 9
	while k <= b:
		ans += a
		k = k * 10 + 9
	print(ans)


def solve(A, B):
	Bcopy = B
	n = 0
	while Bcopy:
		Bcopy //= 10
		n += 1
	cur = 9
	ans = 0
	for i in range(1, n + 3):
		if B >= cur:
			ans += A
			cur = cur * 10 + 9
	return ans
T = int(input())
while T:
	T -= 1
	inp = input().strip().split()
	A = int(inp[0])
	B = int(inp[1])
	print(solve(A, B))


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	c = []
	o = 9
	flag = 0
	while flag != 1:
		if o <= B:
			c.append(o)
			o = o * 10 + 9
			flag = 0
		else:
			flag = 1
	print(A * len(c))


z = int(input())
while z:
	(a, b) = map(int, input().rstrip().split(' '))
	if b < 9:
		print(0)
	else:
		check = len(str(b))
		if 10 ** check - 1 == b:
			print(a * check)
		else:
			print(a * (check - 1))
	z -= 1


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	l = len(str(b))
	if len(str(b + 1)) == l + 1:
		l += 1
	print(a * (l - 1))


import bisect
lol = [0]
for i in range(1, 10):
	lol.append(int('9' * i))
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	n = bisect.bisect(lol, b)
	print((n - 1) * a)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = str(b)
	if len(str(int(c) + 1)) == len(c):
		print(a * (len(c) - 1))
	else:
		print(a * len(c))


def check(x):
	t = 9
	while x >= t:
		t = t * 10 + 9
	return len(str(t)) - 1
q = int(input())
for i in range(q):
	(a, b) = map(int, input().split())
	print(a * check(b))


for nt in range(int(input())):
	(a, b) = map(int, input().split())
	if str(b).count('9') == len(str(b)):
		print(a * len(str(b)))
	else:
		print(a * (len(str(b)) - 1))


from sys import stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]
(T,) = rl()
for _ in range(T):
	(A, B) = rl()
	k = 0
	while 10 ** (k + 1) - 1 <= B:
		k += 1
	print(A * k)


for i in range(int(input())):
	(A, B) = map(int, input().split())
	print(A * (len(str(B + 1)) - 1))


kl = int(input())
for l in range(kl):
	p = [int(i) for i in input().split()]
	k = len(str(p[1]))
	if p[1] + 1 != 10 ** k:
		k -= 1
	print(p[0] * k)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	cnt = 0
	if b < 9:
		print(0)
	else:
		fd = str(b)
		if fd.count('9') == len(fd):
			cnt = len(fd)
		else:
			cnt = len(fd) - 1
		print(a * cnt)


def yet(j):
	l = len(str(j[1]))
	if int('9' * l) > j[1]:
		l -= 1
	return j[0] * l
t = int(input())
l = []
for i in range(t):
	(m, n) = input().split()
	l.append([int(m), int(n)])
for j in l:
	print(yet(j))


n = int(input())
for i in range(n):
	raw = input().split()
	dec = len(raw[1])
	if raw[1] == '9' * dec:
		print(dec * int(raw[0]))
	else:
		print((dec - 1) * int(raw[0]))


import sys
import math
import heapq
import bisect
import re
from collections import deque
from decimal import *
from fractions import gcd

def main():
	(a, b) = [int(i) for i in sys.stdin.readline().split()]
	res = a * len(str(b))
	if b != 10 ** len(str(b)) - 1:
		res -= a
	print(res)
for i in range(int(input())):
	main()


import math
t = int(input())
for T in range(t):
	x = input()
	(a, b) = x.split(' ')
	a = int(a)
	b = int(b)
	n = math.floor(math.log(b, 10) + 1) - 1
	if b == 10 ** (n + 1) - 1:
		n = n + 1
	print(a * n)


def solve(a, b):
	nines = 0
	k = 9
	while k <= b:
		nines += 1
		k = int(str(k) + '9')
	print(a * nines)
t = int(input())
while t > 0:
	t -= 1
	[n, d] = [int(i) for i in input().split()]
	solve(n, d)


import math
t = int(input())
for tc in range(t):
	(A, B) = [int(x) for x in input().split()]
	countb = 0
	blen = len(str(B))
	j = 1
	while j <= blen:
		b = math.pow(10, j) - 1
		if b >= 1 and b <= B:
			countb += 1
		else:
			break
		j += 1
	total = A * countb
	print(total)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(i, ans) = (9, 0)
	while i <= b:
		ans += 1
		i = int(str(i) + '9')
	print(ans * a)


t = int(input())
for _ in range(t):
	(n, a) = [int(i) for i in input().split()]
	a += 1
	print(n * len(str(a)) - n)


t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	ans = int(a) * (len(str(b + 1)) - 1)
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if b == 10 ** len(str(b)) - 1:
		b += 1
	print((len(str(b)) - 1) * a)


from math import log10
t = int(input())
for _ in range(t):
	(a, b) = map(str, input().split())
	if b.count('9') == len(b):
		print(int(a) * len(b))
	else:
		print(int(a) * (len(b) - 1))


import math

def conc(x, y):
	return int(str(x) + str(y))

def program():
	(a, b) = map(int, input().split())
	i = 0
	num = 9
	while num <= b:
		i += 1
		num = conc(num, 9)
	print(a * i)
t = int(input())
for i in range(t):
	program()


def power(x, y):
	res = 1
	while y > 0:
		if y & 1 == 1:
			res = res * x
		y = y >> 1
		x = x * x
	return res
import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	length = 0
	b = str(b)
	len1 = len(b)
	b = int(b)
	val = 0
	for i in range(len1):
		val += power(10, i) * 9
	if b == val:
		length = 1
	length += len1 - 1
	print(a * length)


__author__ = 'tanunia'
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(num_b, k_b) = (0, 0)
	while k_b * 10 + 9 <= b:
		k_b = k_b * 10 + 9
		num_b += 1
	print(a * num_b)


from math import *
t = int(input())
while t > 0:
	(a, b) = [int(x) for x in input().split()]
	org_b = b
	c = 0
	while b > 0:
		b = b // 10
		c += 1
	l = ''
	for i in range(c):
		l += '9'
	d = int(l)
	if org_b != d:
		c -= 1
	print(a * c)
	t -= 1


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	array = [(1, 8), (9, 98), (99, 998), (999, 9998), (9999, 99998), (99999, 999998), (999999, 9999998), (9999999, 99999998), (99999999, 999999998), (999999999, 9999999998), (9999999999, 99999999998), (99999999999, 999999999998), (999999999999, 9999999999998)]
	for i in range(len(array)):
		if b >= array[i][0] and b <= array[i][1]:
			k = i
			break
	print(k * a)


import sys
input = sys.stdin.readline
T = int(input())
import math
for test in range(T):
	(A, B) = map(int, input().split())
	if B + 1 == 10 ** len(str(B)):
		s = len(str(B))
	else:
		s = len(str(B)) - 1
	print(A * s)


arr = []
test_cases = int(input(''))
for x in range(test_cases):
	a = []
	a = list(map(int, input().split()))
	arr.append(a)
for i in range(test_cases):
	Number = int(arr[i][1])
	Count = 0
	while Number > 0:
		Number = Number // 10
		Count = Count + 1
	if arr[i][1] == int(Count * str(9)):
		print(int(arr[i][0]) * Count)
	else:
		print(int(arr[i][0]) * (Count - 1))


t = int(input())
ans = []
for i in range(0, t):
	col = 0
	s = input()
	temp = s.split()
	a = int(temp[0])
	b = int(temp[1])
	while b > 0:
		b = b // 10
		col += 1
	isok = True
	for symbol in temp[1]:
		if symbol != '9':
			isok = False
	if isok:
		ans.append(a * col)
	else:
		ans.append(a * (col - 1))
for element in ans:
	print(element)


t = int(input())
for i in range(t):
	n = 0
	A_B = list(map(int, input().split(' ')))
	(A, B) = A_B
	nin = '9'
	if B < 9:
		print(n)
	else:
		while B >= int(nin):
			n += A
			nin += '9'
		print(n)


t = int(input())
while t > 0:
	t -= 1
	(a, b) = map(int, input().split())
	s = str(b)
	sm = sum(map(int, str(s)))
	l = len(s)
	ans = l - 1
	if sm == 9 * l:
		ans += 1
	res = a * ans
	print(res)


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	val = 1
	ans = 0
	while True:
		x = 10 ** val - 1
		if x > b:
			break
		ans += a
		val += 1
	print(ans)


INF = 10 ** 10

def main():
	(a, b) = get_list()
	r = len(str(b)) - 1
	if list(set(list(str(b))))[0] == '9' and len(set(list(str(b)))) == 1:
		r += 1
	print(a * r)
import sys
import math
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	z = len(str(y)) - 1
	q = str(y).count('9')
	if q == len(str(y)):
		print(x * q)
	else:
		print(z * x)


t = int(input())
for _ in range(t):
	(a, b) = input().split()
	b = int(b)
	a = int(a)
	cnt = 0
	flag = 0
	while b > 0:
		if b % 10 != 9:
			flag = 1
		cnt += 1
		b = b // 10
	if flag == 0:
		print(a * cnt)
	else:
		print(a * (cnt - 1))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	x = len(str(b))
	if not all((k == '9' for k in str(b))):
		x -= 1
	print(a * x)


from math import ceil
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split(' ')))
	b = str(b)
	c = len(b)
	x = 10 ** c
	if int(b) < x - 1:
		c = c - 1
	print(c * a)


def main():
	t = int(input())
	for i in range(t):
		(a, b) = map(int, input().split())
		count1 = a
		b = list(str(b))
		if b.count('9') == len(b):
			count2 = len(b)
		else:
			count2 = len(b) - 1
		print(count1 * count2)
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	m = max(a, b)
	mi = min(a, b)
	l = len(str(b))
	t = int('9' * l)
	if b >= t:
		x = l
	else:
		x = l - 1
	count = a * x
	print(count)


T = int(input())
while T != 0:
	T -= 1
	(a, b) = (int(x) for x in input().split())
	ans = a * (len(str(b + 1)) - 1)
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	tmp = 0
	cnt = 0
	while True:
		tmp = tmp * 10 + 9
		if tmp <= b:
			cnt += 1
		else:
			break
	print(cnt * a)


def digit_count(n):
	cnt = 0
	while n != 0:
		cnt += 1
		n = n // 10
	return cnt
for t in range(int(input())):
	(a, b) = map(int, input().split())
	x = digit_count(b)
	xMax = int('9' * x)
	if b == xMax:
		print(a * x)
	else:
		print(a * (x - 1))


import math
t = int(input())
while t:
	(A, B) = map(int, input().split())
	i = 10
	ans = 0
	no_digits = math.floor(math.log10(B) + 1)
	while i - 1 <= B:
		i *= 10
		ans += 1
	print(ans * A)
	t -= 1


t = int(input())
for iT in range(t):
	(a, b) = [int(i) for i in input().split()]
	temp = 9
	ans = 0
	while temp <= b:
		ans += a
		temp = temp * 10 + 9
	print(ans)


import sys
input = sys.stdin.readline

def solve():
	(A, B) = map(int, input().split())
	n = 0
	cop = B
	ans = 0
	while cop > 0:
		cop = cop // 10
		n += 1
	if B < 10 ** n - 1:
		n -= 1
	print(n * A)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


for tin in range(int(input())):
	(a, b) = map(int, input().split())
	j = []
	for _ in range(len(str(b))):
		if str(b)[_] not in j:
			j.append(str(b)[_])
	if len(j) == 1 and j[0] == '9':
		print(len(str(b)) * a)
	else:
		print((len(str(b)) - 1) * a)


for q in range(int(input())):
	(x, y) = map(int, input().split())
	ys = len(str(y + 1)) - 1
	print(x * ys)


T = int(input())
while T:
	(a, b) = map(int, input().split())
	print(a * (len(str(b + 1)) - 1))
	T -= 1


t = int(input())
for i in range(0, t):
	x = input().split(' ')
	c = int(x[0])
	ch = int(x[1])
	k = 10
	ko = 0
	if ch < 9:
		ko = 0
	elif ch < 99:
		ko = 1
	elif ch < 999:
		ko = 2
	elif ch < 9999:
		ko = 3
	elif ch < 99999:
		ko = 4
	elif ch < 999999:
		ko = 5
	elif ch < 9999999:
		ko = 6
	elif ch < 99999999:
		ko = 7
	elif ch < 999999999:
		ko = 8
	else:
		ko = 9
	print(c * ko)


t = int(input())
for i in range(t):
	c = 0
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	flg = 0
	if b < 9:
		print('0')
	else:
		while b != 0:
			x = b % 10
			if x != 9:
				flg = 1
			c = c + 1
			b = int(b / 10)
		if flg == 1:
			c = c - 1
		v = a * c
		print(v)


from math import log
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = int(log(b + 1, 10))
	if 10 ** x - 1 > b:
		x -= 1
	print(a * x)


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	c = b
	i = 0
	while c > 0:
		c = c // 10
		i += 1
	i = i - (1 if str(b).count('9') != len(str(b)) else 0)
	print(a * i)


_ = int(input())
for ________________________ in range(_):
	(a, b) = map(int, input().split())
	(c, i) = (1, 1)
	while 10 ** i - 1 <= b:
		c += 1
		i += 1
	print(a * (c - 1))


MOD = int(1000000000.0 + 7)

def solv():
	(A, B) = map(int, input().split())
	b = 9
	ans = 0
	while b <= B:
		ans += A
		b = b * 10 + 9
	print(ans)
t = int(input())
for _ in range(t):
	solv()


import math
n = int(input())
ans = []
for i in range(n):
	(a, b) = map(int, input().split())
	ans.append(int(math.log(b + 1, 10)) * a)
for i in range(n):
	print(ans[i])


import math
import sys

def f(x, y):
	num = math.floor(math.log10(y))
	return int(x * 10 ** (1 + num) + y)

def redu(y):
	return math.floor(math.log10(b)) + 1 == math.log10(b + 1)
t = int(input())
for i in range(t):
	(A, B) = map(int, sys.stdin.readline().split())
	count = 0
	c = 9
	while c <= B:
		count += 1
		c = c * 10 + 9
	print(A * count)


t = int(input())
for p in range(t):
	(a, b) = map(int, input().split())
	ll = len(str(b))
	if b == int('9' * ll):
		print(a * ll)
	else:
		print(a * (ll - 1))


for _ in range(int(input())):
	(A, B) = [x for x in input().split()]
	if 10 ** len(B) - 1 <= int(B):
		print(int(A) * len(B))
	else:
		print(int(A) * (len(B) - 1))


T = int(input())
S = [9, 99, 999, 9999, 99999, 9999999, 99999999, 999999999]
for it in range(T):
	(a, b) = map(int, input().split())
	if S.count(b):
		print(a * len(str(b)))
	else:
		print(a * (len(str(b)) - 1))


q = int(input())
for qq in range(q):
	(a, b) = map(int, input().split())
	r = 0
	for i in range(1, 11):
		if b >= 10 ** i - 1:
			r = i
	print(r * a)


t = int(input())
ans = []
for i in range(t):
	(A, B) = map(int, input().split())
	_b = 0
	for g in range(1, 11):
		nine = int('9' * g)
		if B >= nine:
			_b += 1
		else:
			break
	ans.append(_b * A)
for i in range(t):
	print(ans[i])


tc = int(input())
while tc > 0:
	(a, b) = map(int, input().split())
	print(a * (len(str(b + 1)) - 1))
	tc -= 1


import math
z = input
for k in range(int(z())):
	(a, b) = map(int, z().split())
	l = len(str(b))
	p = 10 ** l
	if b >= p - 1:
		print(a * l)
	else:
		print(a * (l - 1))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	b_keta = 0
	div = 9
	for j in range(10):
		if b // div >= 1:
			b_keta += 1
			div = div * 10 + 9
	print(a * b_keta)


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	flag = True
	b = str(b)
	for i in range(len(b)):
		if b[i] != '9':
			flag = False
	ans = a * (len(b) - 1)
	if flag:
		ans += a
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	len_b = len(b)
	if b == '9' * len(b):
		print(int(a) * len_b)
	else:
		print(int(a) * (len_b - 1))


import math
T = int(input())
while T > 0:
	(A, B) = input().split()
	n = int(math.log(int(B) + 1, 10))
	print(int(A) * n)
	T -= 1


import sys, math, cmath
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
t = inp()
for tt in range(t):
	(a, b) = invr()
	q = 1
	if set(list(str(b))) == {'9'}:
		q = 0
	print((len(str(b)) - q) * a)


t = int(input())
while t >= 1:
	inp = input()
	arr = inp.split(' ')
	a = int(arr[0])
	b = int(arr[1])
	i = 9
	cnt = 0
	while i <= b:
		cnt = cnt + 1
		i = i * 10 + 9
	ans = a * cnt
	print(ans)
	t = t - 1


T = int(input())
r = []
for t in range(T):
	(A, B) = [int(x) for x in input().split(' ')]
	l = list(set(str(B)))
	if len(l) == 1:
		_ = int(l[0])
		if _ == 9:
			b = len(str(B))
		else:
			b = len(str(B)) - 1
	else:
		b = len(str(B)) - 1
	r.append(A * b)
for i in r:
	print(i)


for tc in range(int(input())):
	(a, b) = map(int, input().split())
	mxcnt = 0
	mxbase = 9
	while b >= mxbase:
		mxbase = 10 * mxbase + 9
		mxcnt += 1
	print(a * mxcnt)


import math
t = int(input())
for _ in range(t):
	(maxa, maxb) = map(int, input().split())
	maxk = int(math.log10(maxb + 1))
	print(maxk * maxa)


import sys
input = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(a * (len(str(b + 1)) - 1))


t = int(input())
while t > 0:
	t -= 1
	(n, d) = input().split()
	n = int(n)
	l = len(d)
	if 10 ** l - 1 == int(d):
		print(n * l)
	else:
		print(n * (l - 1))


import math
t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	i = 9
	cnt = 0
	while i <= b:
		cnt += 1
		i = i * 10 + 9
	print(cnt * a)


t = int(input())
while t != 0:
	c = 0
	(a, b) = map(int, input().split())
	p = 1
	d = b
	while b:
		b = b // 10
		c += 1
	for i in range(c):
		p *= 10
	if p - 1 == d:
		c = c + 1
	print(a * (c - 1))
	t -= 1


def iinput():
	return [int(i) for i in input().split()]

def conc(x, y):
	return int(str(x) + str(y))
t = int(input())
for i in range(t):
	(A, B) = iinput()
	if B < 9:
		print(0)
	else:
		if str(B) != '9' * len(str(B)):
			ans = (len(str(B)) - 1) * A
		else:
			ans = len(str(B)) * A
		print(ans)


t = int(input())
while t != 0:
	(a, b) = map(int, input().split())
	p = str(b)
	length = len(p)
	digit = ''
	for i in range(length):
		digit += '9'
	digit_nt = int(digit)
	if digit_nt <= b:
		print(length * a)
	else:
		print((length - 1) * a)
	t -= 1


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	ans = 0
	for j in range(1, 10):
		if b >= int('9' * j):
			ans += a
	print(ans)


def main():
	t = int(input())
	for i in range(t):
		inp = input()
		inp = inp.strip().split(' ')
		A = int(inp[0])
		B = int(inp[1])
		L = len(str(B))
		if B + 1 == 10 ** L:
			print(A * L)
		else:
			print(A * L - A)
main()


import math
caso = int(input())
for i in range(caso):
	(a, b) = (int(j) for j in input().split())
	f = int(math.log(b + 1, 10))
	print(a * f)


from math import *
for i in range(int(input())):
	(a, b) = input().split()
	print(int(a) * (len(str(int(b) + 1)) - 1))


t = int(input())
for i in range(t):
	(a, b) = input().strip().split(' ')
	(a, b) = [int(a), int(b)]
	x = 9
	aa = 0
	while b >= x:
		x = 10 * x + 9
		aa += 1
	print(a * aa)


import math
t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	val = math.floor(math.log10(b))
	tmp = set(str(b))
	if len(tmp) == 1 and '9' in tmp:
		val += 1
	print(a * val)


import math
t = int(input())
for _ in range(t):
	(A, B) = [int(x) for x in input().split()]
	print(A * int(math.log10(B + 1)))


t = int(input())
for i in range(t):
	ls = list(map(int, input().split()))
	a = ls[0]
	b = ls[1]
	count = 0
	cur_b = 9
	while cur_b <= b:
		count += a
		cur_b = cur_b * 10 + 9
	print(count)


for i in range(int(input())):
	(x, y) = input().split()
	l = len(y)
	if int(y) % (10 ** l - 1) == 0:
		print(int(x) * l)
	else:
		print(int(x) * (l - 1))


import math
for _ in [0] * int(input()):
	(a, b) = map(int, input().split())
	print(int(math.log10(b + 1)) * a)


I = input
pr = print
for _ in range(int(I())):
	(n, m) = map(int, I().split())
	pr(n * (len(str(m)) - ({x for x in str(m)} != {'9'})))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	cnt = sum((1 for c in range(1, 15) if int('9' * c) <= b))
	print(a * cnt)


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	ans = 0
	for B in range(1, 11):
		b = 10 ** B - 1
		if b > m:
			break
		ans += n
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = input().split()
	var = list(b)
	if var.count('9') == len(var):
		print(int(a) * len(var))
	else:
		print(int(a) * (len(var) - 1))


n = int(input())
a = []
for i in range(n):
	(x, b) = input().split()
	a.append([int(x), int(b)])
for i in a:
	p = 0
	k = len(str(i[1])) - 1
	if i[1] == pow(10, k + 1) - 1:
		k = k + 1
	print(i[0] * k)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
testcases = int(input())
for j in range(testcases):
	(A, B) = map(int, input().split())
	length = len(str(B))
	count = 0
	for s in range(1, length + 1):
		if 10 ** s - 1 <= B:
			count += 1
	print(A * count)


t = int(input())

def conc(f, l):
	return str(f) + str(l)
for x in range(t):
	numbers = input().split(' ')
	a = int(numbers[0])
	b = int(numbers[1])
	numbersCount = len(str(b))
	if pow(10, numbersCount) - 1 > b:
		numbersCount -= 1
	print(numbersCount * a)


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	x = len(str(b))
	if b != int('9' * x):
		x -= 1
	print(a * x)


T = int(input())
while T:
	T -= 1
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	t = b
	bit = 0
	while b > 0:
		b //= 10
		bit += 1
	if t + 1 == 10 ** bit:
		bit += 1
	print((bit - 1) * a)


for _ in range(int(input())):
	X = list(map(int, input().split()))
	Size = len(str(X[1]))
	print(X[0] * (Size if X[1] == int('9' * Size) else Size - 1))


from math import log10, ceil, floor
t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	print(a * floor(log10(b + 1)))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	ans = a * (len(str(b + 1)) - 1)
	print(ans)


for _ in range(int(input())):
	(a, m) = map(int, input().split())
	print(a * (len(str(m)) - 1 + (len(str(m)) == str(m).count('9'))))


t = int(input())
for i in range(t):
	(x, y) = input().split()
	if y == '9':
		y += '9'
	elif y == '99':
		y += '9'
	elif y == '999':
		y += '9'
	elif y == '9999':
		y += '9'
	elif y == '99999':
		y += '9'
	elif y == '999999':
		y += '9'
	elif y == '9999999':
		y += '9'
	elif y == '99999999':
		y += '9'
	elif y == '999999999':
		y += '9'
	print(int(x) * (len(y) - 1))


t = int(input())
arr = []
for _ in range(t):
	arr.append(list(map(int, input().strip().split())))
for i in range(t):
	(a, b) = (arr[i][0], arr[i][1])
	(j, ans) = (1, 0)
	while j < 10 and b >= 10 ** j - 1:
		ans += 1
		j += 1
	print(a * ans)


t = int(input())
import math
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	count = 0
	lenn = len(str(b))
	for i in range(1, lenn + 1):
		if 10 ** i - 1 <= b:
			count = count + 1
	print(count * a)


from math import log10
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(val, cnt) = (10, 0)
	while val - 1 <= b:
		cnt += 1
		val *= 10
	print(a * cnt)


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for _ in range(T):
	(A, B) = map(int, readline().split())
	for k in range(1, 100):
		if 10 ** k - 1 > B:
			break
	print(A * (k - 1))


def f(x):
	t = len(x)
	if set(x) == {'9'}:
		return t
	return t - 1
for i in range(int(input())):
	(x, y) = input().split()
	print(int(x) * f(y))


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	if A < 9 and B < 9:
		print(0)
	else:
		L = len(str(B))
		X = '9' * L
		if B < int(X):
			L = L - 1
		print(L * A)


t = int(input())

def nine(x):
	ans = True
	copy = x + 1
	while copy > 1:
		if copy % 10 != 0:
			ans = False
		copy = copy // 10
	return ans
for i in range(t):
	(a, b) = map(int, input().split())
	if nine(b):
		ans = a * len(str(b))
	else:
		ans = a * (len(str(b)) - 1)
	print(ans)


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	for i in range(1, 10):
		if int('9' * i) <= b:
			ans += 1
	print(a * ans)


t = int(input())
ans = []
nine = {9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999}
for i in range(t):
	(a, b) = map(int, input().split())
	if b in nine:
		b1 = str(b)
		ans.append(a * len(b1))
	else:
		b1 = str(b)
		ans.append(a * (len(b1) - 1))
for i in ans:
	print(i)


n = int(input())
for t in range(n):
	sc = list(map(int, input().split()))
	n = '9'
	cont = 0
	while int(n) <= sc[1]:
		cont += 1
		n = n + '9'
	print(cont * sc[0])


n = int(input())
for i in range(n):
	(a, b) = input().split()
	l = len(b)
	if 10 ** l - 1 > int(b):
		l -= 1
	print(int(a) * l)


for _ in range(int(input())):
	(a1, b1) = map(int, input().split())
	w = len(str(b1))
	b = 10 ** w - 1
	u = len(str(b))
	if b <= b1:
		print(a1 * u)
	else:
		print(a1 * (u - 1))


exec(int(input()) * 'a, b =  map(int, input().split()); print(a * len(str(b + 1)) - a); ')


t = int(input())

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return x * power(x, y - 1)
	else:
		return power(x, y / 2) * power(x, y / 2)
for i in range(t):
	(a, b) = input().split(' ')
	a = int(a)
	if power(10, len(b)) - 1 == int(b):
		print(a * len(b))
		continue
	print(a * (len(b) - 1))


for _ in range(int(input())):
	(A, B) = input().split()
	if '9' * len(B) != B:
		B = B[1:]
	print(len(B) * int(A))


x = int(input())
for i in range(x):
	(a, b) = [z for z in input().split(' ')]
	c = 0
	t = True
	for j in range(len(b)):
		c += 1
		if b[j] != '9':
			t = False
	if not t:
		c -= 1
	print(c * int(a))


from sys import stdin

def solve():
	for _ in range(int(stdin.readline())):
		(A, B) = map(int, stdin.readline().split())
		n = len(str(B))
		b = '9' * n
		if int(b) == B:
			print(A * n)
		else:
			print(A * (n - 1))
solve()


import math
T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	flag = 0
	s = 0
	for i in str(b):
		if i != '9':
			flag = 1
			break
		s += 1
	if flag == 0:
		print(a * s)
	else:
		print(a * (len(str(b)) - 1))


from sys import stdin, stdout

def contaDigitos(b):
	if b < 10:
		return 1
	else:
		return 1 + contaDigitos(b / 10)
nCases = int(stdin.readline())
for i in range(0, nCases):
	(a, b) = [int(x) for x in stdin.readline().rstrip().split()]
	nDigitos = contaDigitos(b + 1)
	print(str(a * (nDigitos - 1)))


t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	x = len(str(n)) - 1
	if set(str(n)) == {'9'}:
		x += 1
	ans = m * x
	print(ans)


t = int(input())
for _ in range(t):
	f = 0
	(a, b) = map(int, input().split())
	x = len(str(b))
	while b > 0:
		d = b % 10
		if d != 9:
			f = 1
			break
		b = b // 10
	if f == 1:
		x = x - 1
	if a == 0:
		print(a + a * x)
	else:
		print(a * x)


t = int(input())
for i in range(t):
	(A, B) = tuple(map(int, input().split()))
	count = 0
	nine = 0
	while B > 0:
		if B % 10 == 9:
			nine += 1
		B = B // 10
		count += 1
	if nine == count:
		print(count * A)
	else:
		print((count - 1) * A)


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve(A, B):
	res = 0
	b = 0
	while True:
		b = b * 10 + 9
		if b > B:
			break
		res += 1
	res *= A
	return res
TC = int(input())
for tc in range(TC):
	(A, B) = map(int, input().split())
	res = solve(A, B)
	print(res)


T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	cnt = 0
	b += 1
	while b != 0:
		cnt += 1
		b //= 10
	print(a * (cnt - 1))


t = int(input())
while t != 0:
	(a, b) = map(int, input().split(' '))
	c = 0
	d = str(b).count('9')
	if d == len(str(b)):
		c = a * d
	elif b > 9:
		c = int(a) * (len(str(b)) - 1)
	print(c)
	t = t - 1


for q in range(int(input())):
	_ = [int(i) for i in input().split()]
	a = _[0]
	b = _[1]
	k = len(str(b))
	z = int('9' * k)
	if z > b:
		k = k - 1
	print(k * a)


c = int(input())
for i in range(c):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	i = 9
	count = 0
	while i <= b:
		count += 1
		i = i * 10 + 9
	print(count * a)


import sys
import math
import itertools
import functools
import collections
import operator

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	(a, b) = mi()
	lb = len(str(b))
	if int('9' * lb) == b:
		print(a * lb)
	else:
		print(a * (lb - 1))


import math
q = int(input())
for _ in range(q):
	(A, B) = list(map(int, input().split(' ')))
	temp = math.log(B + 1, 10) // 1
	temp *= A
	print(int(temp))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	cnt = len(str(b)) - (1 if str(b).count('9') != len(str(b)) else 0)
	print(a * cnt)


from sys import stdin

def solve():
	for _ in range(int(stdin.readline())):
		(A, B) = map(int, stdin.readline().split())
		(b, cnt) = (9, 0)
		while b <= B:
			b *= 10
			b += 9
			cnt += 1
		print(A * cnt)
solve()


t = int(input())
import math
for i in range(t):
	(A, B) = map(int, input().split())
	dig = math.floor(math.log10(B) / math.log10(10)) + 1
	if dig == 1 and B != 9:
		print('0')
		continue
	elif B == int('9' * dig):
		print(dig * A)
	else:
		print((dig - 1) * A)


def calc(a, b):
	k = 0
	if b >= 9:
		k += 1
	if b >= 99:
		k += 1
	if b >= 999:
		k += 1
	if b >= 9999:
		k += 1
	if b >= 99999:
		k += 1
	if b >= 999999:
		k += 1
	if b >= 9999999:
		k += 1
	if b >= 99999999:
		k += 1
	if b >= 999999999:
		k += 1
	return a * k
T = int(input())
for _ in range(T):
	(a, b) = [int(x) for x in input().split()]
	print(calc(a, b))


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
import math
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
t = inp(1)
while t:
	t -= 1
	(a, b) = inp()
	b1 = int(math.log10(b + 1))
	print(a * b1)


t = int(input())
sz = [10 ** i - 1 for i in range(1, 20)]
for i in range(t):
	(A, B) = [int(x) for x in input().split()]
	ans = 0
	for j in sz:
		if B >= j:
			ans += 1
	ans *= A
	print(ans)


t = int(input())

def returnAllNineStatus(integer):
	for i in str(integer):
		if i == '9':
			continue
		else:
			return False
	return True
for i in range(t):
	(A, B) = map(int, input().split(' '))
	multiplier = 0
	if B < 9:
		print(0)
		continue
	elif returnAllNineStatus(B):
		print(A * len(str(B)))
	else:
		print(A * (len(str(B)) - 1))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = 9
	count = 0
	while x <= b:
		count += 1
		x = int(str(x) + '9')
	print(a * count)


def solve():
	(a, b) = map(int, input().strip().split())
	b += 1
	ans = a * (len(str(b)) - 1)
	print(ans)
t = int(input().strip())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	n = len(str(B))
	if len(str(B + 1)) > len(str(B)):
		n += 1
	print(A * (n - 1))


import math
t = int(input())
while t > 0:
	str1 = input()
	lst = str1.split()
	len1 = len(lst[1])
	ans = 0
	if lst[1] == '9' * len1:
		ans = int(lst[0]) * len1
	else:
		ans = int(lst[0]) * (len1 - 1)
	print(ans)
	t = t - 1


def func(a, b):
	n = len(str(b))
	s1 = '9' * n
	if b // int(s1) > 0:
		return a * n
	else:
		return a * (n - 1)
t = int(input())
for _ in range(t):
	s = list(map(int, input().split()))
	(a, b) = (s[0], s[1])
	print(func(a, b))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = len(str(b)) - 1
	if b == int('9' * len(str(b))):
		c += 1
	print(a * c)


def solve(x, c, y, u):
	if x * 10 + 9 > y:
		print(u * c)
		return
	solve(x * 10 + 9, c + 1, y, u)
for i in range(int(input())):
	(n, m) = map(int, input().split())
	solve(0, 0, m, n)


n = int(input())
for i in range(n):
	lst = list(map(int, input().split()))
	a = lst[0]
	b = lst[1]
	nlist = 0
	for k in range(9, -1, -1):
		nl = 10 ** k - 1
		if b - nl >= 0:
			break
	print(a * k)


a = int(input())
for i in range(0, a):
	b = list(map(int, input().split()))
	if (b[1] + 1) % 10 ** len(str(b[1])) == 0:
		m = len(str(b[1])) * b[0]
	else:
		m = (len(str(b[1])) - 1) * b[0]
	print(m)


getLimit = int(input())
Result = []
for i in range(1, getLimit + 1):
	noException = True
	AB_List = list(map(int, input().strip().split()))[:2]
	String = AB_List[1]
	for j in str(String):
		if j is not '9':
			noException = False
			break
	if noException is True:
		getLen = len(str(AB_List[1]))
	else:
		getLen = len(str(AB_List[1])) - 1
	numOfPairs = AB_List[0] * getLen
	Result.append(numOfPairs)
for i in range(0, getLimit):
	Show = Result[i]
	print(Show)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ct = 0
	temp = b
	a1 = []
	while temp != 0:
		a1 += [temp % 10]
		temp //= 10
		ct += 1
	fl = 0
	for i in a1:
		if i != 9:
			fl = 1
			break
	if fl == 1:
		print(a * (len(a1) - 1))
	else:
		print(a * len(a1))


n = int(input())
for i in range(n):
	a = list(map(int, input().strip().split()))[:2]
	i = 1
	count = 0
	while 10 ** i - 1 <= a[1]:
		i += 1
		count += 1
	print(count * a[0])


t = int(input())
for q in range(t):
	(a, b) = map(int, input().split())
	s2 = len(str(b))
	if int('9' * s2) > b:
		print((s2 - 1) * a)
	else:
		print(s2 * a)


import math
t = int(input(''))
while t > 0:
	(a, b) = input('').split()
	a = int(a)
	b = int(b)
	count = 0
	for i in range(1, len(str(b)) + 1):
		if b >= 10 ** i - 1:
			count += 1
	print(count * a)
	t = t - 1


from math import log10
T = int(input())
while T:
	T -= 1
	(A, B) = map(int, input().split())
	s = 1
	ans = 0
	for i in range(10):
		b = s - 1
		if B >= b >= 1:
			ans += A
		s *= 10
	print(ans)


def all_9(b):
	b = str(b)
	l = []
	for x in b:
		l.append(x)
	b = list(set(l))
	if b[0] == '9' and len(b) == 1:
		return True
	else:
		return False
t = int(input())
while t:
	t -= 1
	(a, b) = [int(x) for x in input().split(' ')]
	if all_9(b):
		print(a * len(str(b)))
	else:
		print(a * (len(str(b)) - 1))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	cnt = 0
	i = 9
	while i <= b:
		i = int(str(i) + '9')
		cnt = cnt + a
	print(cnt)


for _ in range(int(input())):
	l = list(input().split())
	a = l[0]
	b = l[1]
	x = len(b)
	if '9' * len(b) != b:
		x = x - 1
	print(int(a) * x)


mod = 10 ** 9 + 7
import math
from collections import Counter
from itertools import combinations
import math

def ain():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	(a, b) = ain()
	c = int(math.log(b + 1, 10))
	print(a * c)


def getorder(a):
	count = 0
	while a > 0:
		a = int(a / 10)
		count = count + 1
	return count
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = getorder(b)
	if b == 10 ** x - 1:
		print(a * x)
	else:
		print(a * (x - 1))


import math
t = int(input())
for i in range(t):
	(n, d) = map(int, input().split())
	b = ''
	while 1:
		if int(b + '9') <= d:
			b += '9'
		else:
			break
	print(len(b) * n)


T = int(input())
for kase in range(T):
	(a, b) = [int(x) for x in input().split()]
	x = 9
	ans = 0
	while x <= b:
		ans += 1
		x = x * 10 + 9
	print(ans * a)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	k = len(str(b))
	if b < 9:
		print(0)
	elif b != 10 ** k - 1:
		print(a * (k - 1))
	else:
		print(a * k)


N = int(input())
for _ in range(N):
	(A, B) = map(int, input().split())
	print((len(str(B + 1)) - 1) * A)


from sys import *
from math import *
from bisect import *
t = int(stdin.readline())
for _ in range(t):
	(a, b) = map(int, stdin.readline().split())
	x = int(log10(b))
	if 10 ** (x + 1) - 1 == b:
		x += 1
	print(a * x)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	B = str(b)
	tamB = len(B)
	f = True
	for i in range(tamB):
		if B[i] != '9':
			f = False
			break
	if f == False:
		tamB -= 1
	res2 = tamB * a
	print(res2)


for x in range(int(input())):
	(h, m) = list(map(int, input().split()))
	k = 0
	z = 0
	while k * 10 + 9 <= m:
		k = k * 10 + 9
		z += 1
	print(h * z)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = '1'
	cnt = 0
	while int(s) * 9 <= b:
		s = s + '1'
		cnt = cnt + 1
	print(a * cnt)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(a, b) = inputnums()
	print(a * (len(str(b + 1)) - 1))


import math
for _ in range(int(input())):
	(A, B) = map(int, input().split(' '))
	print(math.floor(math.log10(B + 1)) * A)


t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	B += 1
	x = len(str(B)) - 1
	print(A * x)


from collections import Counter
t = int(input())
for test in range(t):
	(a, b) = [int(x) for x in input().split()]
	y = len(str(b + 1)) - 1
	print(a * y)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))))

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]

def give9(a):
	curr = 9
	le = len(str(a))
	tot = 0
	while curr <= a and len(str(curr)) <= le:
		tot += 1
		curr *= 10
		curr += 9
	return tot
for _ in range(val()):
	(a, b) = li()
	print(a * give9(b))


def getNum(a, b):
	s1 = str(a)
	s2 = str(b)
	s = s1 + s2
	num = int(s)
	return num
t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split(' '))
	count = 0
	stb = str(B)
	n = len(stb)
	if '9' * n == stb:
		print(A * n)
	else:
		print(A * (n - 1))


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	(a, b) = map(int, I().split())
	x = 0
	c = 9
	while c <= b:
		x += 1
		c = int('9' * (len(str(c)) + 1))
	ans += str(a * x) + '\n'
print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	i = 0
	res = 0
	while b >= i * 10 + 9:
		res += a
		i = i * 10 + 9
	print(res)


import sys, itertools, math
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b) = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	s = a * int(math.log10(b))
	if b == 10 ** (int(math.log10(b)) + 1) - 1:
		s += a
	print(s)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	len_b = len(str(b + 1))
	result = a * (len_b - 1)
	print(result)


T = int(input())
for i in range(T):
	(a, b) = map(int, input().split())
	k = len(str(b))
	print(a * (k - 1 + (b == 10 ** k - 1)))


t = int(input())
for q in range(t):
	(a, b) = [int(i) for i in input().split()]
	if b < 9:
		print(0)
		continue
	if b == 9 or b == 10:
		print(a)
		continue
	ans = 0
	if len(set(str(b))) and list(set(str(b))) == ['9']:
		ans += len(str(b))
	else:
		ans += len(str(b)) - 1
	print(ans * a)


exec(int(input()) * "a,b=map(int,input().split());print(a*len(f'{b+1}')-a);")


from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return [list(x) for x in sys.stdin.readline().split()]

def S():
	res = list(sys.stdin.readline())
	if res[-1] == '\n':
		return res[:-1]
	return res

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
	t = I()
	for i in range(t):
		(a, b) = LI()
		d = len(str(b + 1)) - 1
		print(a * d)
	return

def __starting_point():
	solve()
__starting_point()


from sys import stdin, stdout
from sys import maxsize
input = stdin.readline

def solve():
	pass
test = 1
test = int(input().strip())
for t in range(0, test):
	(n, k) = list(map(int, input().strip().split()))
	s = [x for x in str(k)]
	ans = True
	for el in s:
		if el != '9':
			ans = False
	if ans:
		print(n * len(s))
	else:
		print(n * (len(s) - 1))
	ans = solve()


def count(b):
	b += 1
	c = 0
	while b:
		c += 1
		b //= 10
	return c - 1
t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split(' ')]
	print(a * count(b))


numTestcases = int(input())
ans = []

def checkLength(num):
	testN = num
	numDigits = 0
	while testN > 0:
		testN = testN // 10
		numDigits += 1
	return numDigits
for i in range(numTestcases):
	currentLine = list(map(int, input().split(' ')))
	a = currentLine[0]
	b = currentLine[1]
	cAns = a * (checkLength(b + 1) - 1)
	ans.append(str(cAns))
print('\n'.join(ans))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	(x, y) = get_list()
	b = '9'
	i = 1
	while int(b) <= y:
		i += 1
		b = '9' * i
	print((i - 1) * x)


import itertools as it
n = int(input())
for plk in range(n):
	(A, B) = map(int, input().split())
	c = 0
	b = 9
	while b <= B:
		c += A
		b = b * 10 + 9
	print(c)


from math import *
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = int(log10(b))
	sn = a * s
	t = '9' * (s + 1)
	t = int(t)
	if t == b:
		sn += a
	print(sn)


t = int(input())
soma = 0
mel = '9'
for i in range(t):
	(a, b) = input().split()
	if int(mel) > int(b):
		print('0')
	else:
		while int(mel) <= int(b):
			soma += int(a)
			mel = mel + '9'
		print(soma)
		mel = '9'
		soma = 0


t = int(input())
while t:
	t -= 1
	(a, b) = list(map(int, input().split()))
	print(a * (len(str(int(b) + 1)) - 1))


t = int(input())
for i in range(t):
	(a, b) = [int(i) for i in input().split()]
	s = 0
	p = 10
	while b >= p - 1:
		s += 1
		p *= 10
	print(a * s)


T = int(input())

def draft(B):
	if len(str(B)) + 1 == len(str(B + 1)):
		return len(str(B))
	else:
		return len(str(B)) - 1
while T > 0:
	T -= 1
	(A, B) = map(int, input().split())
	D = draft(B)
	print(A * D)


t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	count9 = 0
	drinum = 9
	while drinum <= b:
		count9 += 1
		drinum = drinum * 10 + 9
	print(count9 * a)


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	if B == 9 or B == 99 or B == 999 or (B == 9999) or (B == 99999) or (B == 999999) or (B == 9999999) or (B == 99999999) or (B == 999999999):
		print(A * len(str(B)))
	else:
		print(A * (len(str(B)) - 1))


def bs(val):
	(l, r) = (0, 20)
	while r - l > 1:
		m = (r + l) // 2
		nines = int('9' * m)
		if nines <= val:
			l = m
		else:
			r = m
	if l < 0:
		return r
	return l
t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	X = bs(B)
	print(A * X)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	pr = 10
	ans = 0
	while pr - 1 <= b:
		ans += a
		pr *= 10
	print(ans)


for t in range(int(input())):
	(a, b) = [*map(int, input().split())]
	print(a * (len(str(b)) - (0 if str(b + 1).count('0') == len(str(b)) else 1)))


T = int(input())
for t in range(T):
	(A, B) = input().split()
	A = int(A)
	b = len(list(B))
	if int(B) < 10 ** b - 1:
		b -= 1
	print(A * b)


for u in range(int(input())):
	(x, y) = map(int, input().split())
	if y == int('9' * len(str(y))):
		print(x * len(str(y)))
	else:
		print(x * (len(str(y)) - 1))


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	if l[0] < 9 and l[1] < 9:
		print('0')
	else:
		m = str(l[1])
		s = set(m)
		if len(s) == 1 and '9' in s:
			print(len(m) * l[0])
		else:
			print((len(m) - 1) * l[0])


import sys
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(a, b) = [int(item) for item in input().split()]
	blen = len(str(b + 1))
	print(a * (blen - 1))


from math import *
t = int(input())
for y in range(t):
	(n, m) = map(int, input().split())
	d = 0
	m1 = m
	while m > 0:
		d += 1
		m //= 10
	if 10 ** d - 1 > m1:
		d -= 1
	print(n * d)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	p10 = 10
	res = 0
	while p10 - 1 <= b:
		res += a
		p10 *= 10
	print(res)


t = int(input())
for q in range(t):
	ab = input().split()
	A = int(ab[0])
	B = int(ab[1])
	x = str(9) * len(str(B))
	max9 = 0
	if int(x) <= B:
		max9 = len(str(B))
	else:
		max9 = len(str(B)) - 1
	print(A * max9)


def test(a, b):
	ret = 0
	for i in range(1, a + 1):
		for j in range(1, b + 1):
			if i * j + i + j == conc(i, j):
				ret += 1
	return ret

def conc(a, b):
	return int(str(a) + str(b))
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	cnt = 0
	for n in range(1, 10):
		if 1 <= pow(10, n) - 1 <= b:
			cnt += 1
	cnt *= a
	print(cnt)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	k = '9'
	ans = 0
	while int(k) <= b:
		k += '9'
		ans += a
	print(ans)


import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	bs = len(str(b + 1)) - 1
	print(a * bs)


for _ in range(int(input())):
	(a, b) = input().split()
	count = 0
	l = len(b)
	for i in range(0, l):
		if b[i] == '9':
			count += 1
	if count == l:
		print(l * int(a))
	else:
		print((l - 1) * int(a))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	y %= p - 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)
mod = 10 ** 9 + 7

def solve(case):
	(a, b) = sep()
	hi = ''
	for i in range(len(str(b))):
		hi += '9'
	hi = int(hi)
	if b == hi:
		print(a * len(str(b)))
	else:
		print(a * (len(str(b)) - 1))
testcase(int(inp()))


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	ans = 0
	t = '9'
	while int(t) <= B:
		ans += A
		t += '9'
	print(ans)


from sys import stdin, stdout
import math
import bisect
input = stdin.readline

def print(x='', y='', end='\n'):
	if y == '':
		stdout.write(str(x) + end)
	else:
		stdout.write(str(x) + ' ' + str(y) + end)

def solve():
	(a, b) = map(int, input().split())
	c = len(str(b + 1))
	print(a * (c - 1))
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


def main():
	t = int(input())
	for i in range(t):
		(A, B) = map(int, input().split())
		cb = len(str(B))
		if B == int('9' * cb):
			print(A * cb)
		else:
			print(A * (cb - 1))
main()


t = int(input())
while t:
	(a, b) = map(int, input().split())
	l = False
	for i in str(b):
		if i != '9':
			l = True
	if l:
		c = len(str(b)) - 1
	else:
		c = len(str(b))
	print(a * c)
	t -= 1


for tt in range(int(input())):
	(A, B) = list(map(int, input().split()))
	bct = 0
	for nn in range(1, 11):
		if 10 ** nn < B + 2:
			bct += 1
		else:
			break
	print(A * bct)


for _ in range(int(input())):
	(a, b) = (int(x) for x in input().strip().split())
	t = len(str(b)) - 1
	if str(b).count('9') == len(str(b)):
		t += 1
	t = t * a
	print(t)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(a, b) = invr()
	k = 0
	noy = 9
	while noy <= b:
		k += 1
		noy *= 10
		noy += 9
	print(a * k)


n = int(input())
for t in range(n):
	(m, k) = map(str, input().split())
	r = len(k)
	t = k.count('9')
	if t == r:
		print(r * int(m))
	else:
		print((r - 1) * int(m))


t = int(input())
while t:
	(A, B) = map(int, input().split(' '))
	b = 9
	ans = 0
	while b <= B:
		ans += A
		b = 10 * b + 9
	print(ans)
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b < 9:
		print(0)
	else:
		l = len(str(b))
		if b < 10 ** l - 1:
			l -= 1
		print(a * l)


import math
t = int(input())
for _ in range(t):
	(a, b) = map(str, input().split())
	a = int(a)
	z = int(b)
	b = list(b)
	l = len(b)
	s = ''
	for i in range(l):
		s += '9'
	s = int(s)
	if s == z:
		k = l
	else:
		k = l - 1
	print(a * k)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	d = str(b + 1)
	c = len(d)
	x = a * (c - 1)
	print(x)


t = int(input())
while t:
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	print(x * (len(str(y + 1)) - 1))
	t = t - 1


for i in range(int(input())):
	(a, b) = map(int, input().split(' '))
	j = 9
	while j > 0:
		if b // (10 ** j - 1):
			break
		j = j - 1
	print(j * a)


t = int(input())
for i in range(0, t):
	(a, b) = map(int, input().split())
	p = 0
	while b >= 9:
		b = int((b - 9) / 10)
		p += a
	print(p)


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	(i, j) = (0, 9)
	while j <= b:
		i += 1
		j *= 10
		j += 9
	print(a * i)


t = int(input())
for _ in range(t):
	c = 0
	arr = 0
	(a, b) = [int(x) for x in input().split()]
	for i in range(10):
		c = c * 10 + 9
		if c <= b:
			arr += a
	print(arr)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
from typing import List

def solve(A, B):
	b = B
	blen = 0
	while b > 0:
		blen += 1
		b //= 10
	if B != 10 ** blen - 1:
		blen -= 1
	return A * blen
T = int(input())
for ti in range(T):
	(a, b) = map(int, input().split())
	print(solve(a, b))


import math
for i in range(int(input())):
	(A, B) = list(map(int, input().split()))
	if B == 1:
		db = 1
	else:
		db = math.ceil(math.log(B, 10))
	if B >= int('9' * db):
		print(db * A)
	else:
		print((db - 1) * A)


import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	print(n * (len(str(k + 1)) - 1))


n = int(input())
lst = []
for i in range(n):
	lst.append(list(map(int, input().split())))
for i in lst:
	(a, b) = (i[0], i[1])
	print(a * (len(str(b + 1)) - 1))


import math

def solve(a, b):
	if b < 9:
		return 0
	else:
		s = str(b)
		if s.count('9') == len(s):
			return a * len(s)
		else:
			return a * (len(s) - 1)
t = int(input())
while t:
	(n, d) = map(int, input().split())
	print(solve(n, d))
	t -= 1


from math import ceil

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def si():
	return input()
t = ii()
while t:
	t -= 1
	(a, b) = mi()
	x = 9
	c = 0
	while b >= x:
		c += 1
		x = x * 10 + 9
	print(a * c)


import math
t = int(input())
while t > 0:
	temp = input()
	s = temp.split(' ')
	a = int(s[0])
	b = int(s[1])
	length = int(math.floor(math.log10(b)))
	if 10 ** (length + 1) - b == 1:
		print((length + 1) * a)
	else:
		print(length * a)
	t = t - 1


from decimal import Decimal
t = int(input())
for i in range(t):
	(A, B) = map(Decimal, input().split())
	print(A * int(Decimal(B + 1).log10()))


t = int(input())
for _ in range(0, t):
	(a, b) = map(int, input().split())
	temp = 0
	t = b
	while t > 0:
		temp += 1
		t //= 10
	if b == 10 ** temp - 1:
		temp += 1
	ans = a * (temp - 1)
	print(ans)


import sys
import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = b
	c = 0
	while x != 0:
		c += 1
		x = x // 10
	if b == pow(10, c) - 1:
		c += 1
	print(a * (c - 1))


from math import log10, floor

def intLog(x):
	(count, n) = (0, 1)
	while n <= x:
		n *= 10
		count += 1
	return count - 1
ans = []
for i in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	temp = intLog(b)
	if b == 10 ** (temp + 1) - 1:
		temp += 1
	ans.append(str(a * floor(temp)))
print('\n'.join(ans))


import sys

def go(num, concat):
	global cnt
	if int(concat) > num:
		return
	cnt += 1
	go(num, concat + '9')
tc = int(sys.stdin.readline())
for _ in range(tc):
	(a, b) = map(int, sys.stdin.readline().split())
	cnt = 0
	go(b, '9')
	print(a * cnt)


t = int(input())
for i in range(t):
	(A, B) = map(str, input().split())
	a = int(A)
	if B.count('9') == len(B):
		print(a * len(B))
	else:
		print(a * (len(B) - 1))


t = int(input())
for temp in range(t):
	temp = input().split()
	(n, d) = (int(temp[0]), int(temp[1]))
	sz = len(str(d + 1)) - 1
	print(n * sz)


import math
t = int(input())
for i in range(0, t):
	(A, B) = [int(j) for j in input().split()]
	print(A * math.floor(math.log10(B + 1)))


for t in range(int(input())):
	(a, b) = map(int, input().split())
	lb = len(str(b))
	s = 0
	qb = []
	for i in range(lb):
		qb.append(9)
	sb = int(''.join(map(str, qb)))
	if int(sb) > b:
		s += (lb - 1) * a
	else:
		s += lb * a
	print(s)


n = int(input())
res = [0] * n
for i in range(0, n):
	(a, b) = map(int, input().split())
	res[i] = a * (len(str(b + 1)) - 1)
print(*res, sep='\n')


count = int(input())
for i in range(count):
	data = list(map(int, input().split()))
	num1 = int(data[0])
	num2 = int(data[1])
	f = len(str(num2)) - 1
	if len(str(num2 + 1)) == len(str(num2)) + 1:
		f += 1
	print(num1 * f)


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(a, b) = Read.list_int()
	l = len(str(b))
	if int(l * '9') != b:
		l -= 1
	print(l * a)
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


N = int(input())
for _ in range(N):
	(a, b) = map(int, input().split())
	c = 10
	ans = 0
	while c - 1 <= b:
		ans += a
		c *= 10
	print(ans)


import sys
from bisect import bisect_left as bl, bisect_right as br, bisect
import math
from itertools import zip_longest as zl
from itertools import groupby as gb
from itertools import combinations as comb
from itertools import combinations_with_replacement as cwr
from collections import defaultdict as dd
from collections import deque as dq
from collections import Counter as c
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return input()

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
for _ in range(int(data())):
	(A, B) = sp()
	length = len(str(B))
	if B == pow(10, length) - 1:
		print(A * length)
	else:
		print(A * (length - 1))


t = int(input())
inputs = [list(map(int, input().split(' '))) for i in range(t)]
res = []
for i in range(len(inputs)):
	if inputs[i][1] < int(len(str(inputs[i][1])) * '9'):
		res.append(str((len(str(inputs[i][1])) - 1) * inputs[i][0]))
	else:
		res.append(str(len(str(inputs[i][1])) * inputs[i][0]))
print('\n'.join(res))


for x in range(int(input())):
	t = [int(i) for i in input().split()]
	A = t[0]
	B = t[1]
	total = 0
	print(A * (len(str(B + 1)) - 1))


import math
for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	c = int(math.log(b, 10))
	if b + 1 == 10 ** (c + 1):
		c += 1
	print(a * c)


t = eval(input())
for i in range(t):
	(A, B) = map(int, input().split())
	ans = 0
	cnt = 9
	while cnt <= B:
		ans += 1
		cnt = cnt * 10 + 9
	print(ans * A)


def checkN(string):
	for ele in string:
		if ele != '9':
			return False
	return True

def meme():
	for _ in range(t):
		(a, b) = [int(x) for x in input().split()]
		strb = str(b)
		if checkN(strb):
			res1 = a * len(str(b))
		else:
			res1 = a * (len(str(b)) - 1)
		yield res1
t = int(input())
ans = meme()
print(*ans, sep='\n')


t = int(input())
from math import log
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	b = str(b)
	ll = len(b) - 1
	flg = 0
	for i in b:
		if i != '9':
			flg = 1
	if flg == 0:
		ll += 1
	print(ll * a)


T = int(input())
for t in range(T):
	read = input().split()
	A = int(read[0])
	B = int(read[1])
	cnt = 0
	b = 0
	while b <= B:
		if b * 10 + 9 <= B:
			cnt += 1
		b = b * 10 + 9
	print(A * cnt)


import math
t = int(input(''))
while t > 0:
	(a, b) = input('').split()
	p = int(a)
	q = int(b)
	count = len(b) - 1
	if b == '9' * len(b):
		count += 1
	print(count * p)
	t = t - 1


T = int(input())
for _ in range(T):
	(A, B) = map(int, input().split())
	ans = 0
	for i in range(1, 10):
		if 10 ** i - 1 > B:
			break
		ans += A
	print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(a, b) = LI()
		r = 0
		t = 1
		while b >= 10 ** t - 1:
			r += a
			t += 1
		rr.append(r)
	return JA(rr, '\n')
print(main())


t = int(input())
for q in range(t):
	(a, b) = map(int, input().split())
	cnt = 0
	b += 1
	while b > 0:
		b //= 10
		cnt += 1
	print(a * (cnt - 1))


t = int(input())

def conc(a, b):
	return int(str(a) + str(b))
for _ in range(t):
	(a, b) = map(int, input().split())
	m = len(str(b + 1)) - 1
	print(a * m)


n = int(input())
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	print(a * (len(b) - 1) + a * int(int(b) / int('9' * len(b))))


for _ in range(int(input())):
	(A, B) = [int(x) for x in input().split()]
	for max_length_b in range(1, 11):
		if int('9' * max_length_b) > B:
			max_length_b -= 1
			break
	solutions = A * max_length_b
	print(solutions)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	l = len(str(b + 1))
	print(a * (l - 1))


from sys import stdin
t = int(stdin.readline())
while t:
	(a, b) = map(int, stdin.readline().split())
	l = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]
	d = sum((i <= b for i in l))
	print(d * a)
	t -= 1


tests = int(input())
for _ in range(tests):
	(A, B) = input().split(' ')
	result = int(A) * (len(str(int(B) + 1)) - 1)
	print(result)


def main():
	t = int(input())
	for i in range(t):
		v = input()
		v = v.split(' ')
		A = int(v[0])
		B = int(v[1])
		res = get_count_2(A, B)
		print(res)

def get_count_2(A, B):
	count = 0
	n = 1
	while True:
		y = 10 ** n - 1
		if y > B:
			break
		conc_max = str(A) + str(B)
		conc_max_int = int(conc_max)
		max_x = min(conc_max_int // y, A)
		if max_x < 1:
			break
		count += max_x
		n += 1
	return count
main()


T = int(input())
for cs in range(T):
	(A, B) = map(int, input().split())
	i = 9
	sum = 0
	while i <= B:
		sum += A
		i = 10 * i + 9
	print(sum)


q = int(input())
for i in range(q):
	(a, b) = map(int, input().split())
	r = len(str(b))
	if b < int('9' * r):
		r = r - 1
	print(a * r)


import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	y = math.floor(math.log10(b + 1))
	print(y * a)


t = int(input())
for i in range(0, t):
	(a, b) = [int(x) for x in input().split()]
	possa = a
	bb = str(b)
	n = len(bb)
	strb2 = '9' * n
	if strb2 == bb:
		possb = n
	else:
		possb = n - 1
	print(possa * possb)


n1 = int(input())
a = list()
for i in range(n1):
	s = input().split()
	(n, m) = (int(s[0]), int(s[1]))
	st = '1' * len(str(m))
	if m == 9 * int(st):
		a.append(n * len(str(m)))
	else:
		m = str(m)
		a.append(n * (len(m) - 1))
for i in a:
	print(i)


import math
t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	c = 0
	x = int(math.log10(b))
	c = x * a
	if b == pow(10, x + 1) - 1:
		c += a
	print(c)
	t = t - 1


import math
import sys
input = sys.stdin.readline

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for i in range(inin()):
	(a, b) = map(str, input().split())
	l = len(b)
	if b == '9' * l:
		l += 1
	print(int(a) * (l - 1))


n = int(input())
for i in range(n):
	(A, B) = map(int, input().split())
	l = 1
	ans = 0
	while 10 ** l - 1 <= B:
		ans += 1
		l += 1
	print(ans * A)


import math
t = int(input())
for i in range(t):
	ans = 0
	(A, B) = map(int, input().split())
	len1 = len(str(B))
	if 10 ** len1 == B + 1:
		print(A * len1)
	else:
		print(A * (len1 - 1))


import sys
input = sys.stdin.readline
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for (a, b) in Query:
	n = 0
	while True:
		if 10 ** (n + 1) - 1 > b:
			break
		n += 1
	print(a * n)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	n_a = 0
	temp = 0
	while temp < a:
		temp += 9
		if temp <= a:
			n_a += 1
			temp *= 10
		else:
			break
	n_b = 0
	temp = 0
	while temp < b:
		temp += 9
		if temp <= b:
			n_b += 1
			temp *= 10
		else:
			break
	print(n_b * a)


t = int(input())
for x in range(t):
	(a, b) = map(int, input().split())
	if len(str(b + 1)) == len(str(b)):
		print((len(str(b)) - 1) * a)
	else:
		print(len(str(b)) * a)


T = int(input())
for t in range(T):
	(n, d) = map(int, input().split())
	print(n * (len(str(d + 1)) - 1))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

def solve():
	(a, b) = sep()
	t = int(len(str(b + 1))) - 1
	print(a * t)
testcase(int(inp()))


from sys import stdin, stdout
T = int(stdin.readline().strip())
for case in range(T):
	(a, b) = map(int, stdin.readline().strip().split())
	c = 0
	for i in range(1, 12):
		x = '9' * i
		if int(x) > b:
			break
		c = i
	print(a * c)


from sys import stdin, stdout
import gc
gc.disable()
input = stdin.readline
import math
arr = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]
t = int(input().strip())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	end = 0
	for i in range(len(arr)):
		if b >= arr[i]:
			pass
		else:
			end = i
			break
	else:
		end = 9
	print(a * end)


def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split(' '))
		b = b + 1
		print(a * (len(str(b)) - 1))
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	cnt = 0
	ans = 0
	while cnt <= m:
		ans += 1
		cnt = cnt * 10
		cnt += 9
	ans -= 1
	print(n * ans)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b) = map(int, sys.stdin.readline().split())
	cc = 0
	n = len(str(b))
	if '9' * n == str(b):
		cc = a * n
	else:
		cc = a * (n - 1)
	sys.stdout.write(str(cc) + '\n')


t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	k = len(str(B))
	if B < 9:
		print(0)
	elif B != 10 ** k - 1:
		print(A * (k - 1))
	else:
		print(A * k)


n = int(input())

def solve(b):
	if b < 9:
		return 0
	elif b < 99:
		return 1
	elif b < 999:
		return 2
	elif b < 9999:
		return 3
	elif b < 99999:
		return 4
	elif b < 999999:
		return 5
	elif b < 9999999:
		return 6
	elif b < 99999999:
		return 7
	elif b < 999999999:
		return 8
	elif b <= 1000000000:
		return 9
for _ in range(n):
	(a, b) = map(int, input().split())
	c = solve(b)
	print(a * c)


import math
n = int(input())
for i in range(n):
	(a, d) = map(int, input().split())
	f = d + 1
	c = 0
	l = math.log(f, 10)
	if math.floor(l) == math.ceil(l):
		c += 1
	p = a * (len(str(d)) - 1 + c)
	print(p)


import math

def solve():
	(a, b) = map(int, input().split())
	n = 0
	flag = True
	while b:
		remain = b % 10
		if remain != 9:
			flag = False
		b //= 10
		n += 1
	if not flag:
		n -= 1
	print(a * n)
for _ in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	List = input().split()
	if int(List[1]) == int('9' * len(List[1])):
		b = len(List[1])
	else:
		b = len(List[1]) - 1
	print(int(List[0]) * b)


import os, sys
from io import BytesIO, IOBase

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import math
for i in range(ii()):
	(a, b) = mi()
	c = 0
	l = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]
	c = 0
	for i in range(len(l)):
		if b >= l[i]:
			c += 1
	print(a * c)


t = int(input())
while t > 0:
	(A, B) = list(map(int, input().split()))
	if B < 0:
		print(0)
	else:
		u = len(str(B))
		aList = [int('9' * i) for i in range(1, u + 1) if int('9' * i) <= B]
		print(len(aList) * A)
	t -= 1


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	l = len(str(b))
	if b == 10 ** l - 1:
		ans = a * l
	else:
		ans = a * (l - 1)
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	count = 0
	for i in range(1, 10):
		if 10 ** i - 1 <= b:
			count += 1
		else:
			break
	print(count * a)


a = int(input())
for x in range(a):
	(b, c) = map(int, input().split())
	x = 1
	st = str(c)
	w = len(st) - 1
	count = b * w
	if (c + 1) % 10 ** (w + 1) == 0:
		count += b
	print(count)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def solve():
	(a, b) = map(int, input().split())
	B = len(str(b)) - 1
	if len(str(b)) != len(str(b + 1)):
		B += 1
	print(a * B)
t = int(input())
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	B = str(B)
	if B.count('9') == len(B):
		l = len(B)
	else:
		l = len(B) - 1
	print(A * l)


import math
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().rstrip().split()))
	b = str(b)
	tmp = len(b) - 1
	if b.count('9') == len(b):
		tmp += 1
	print(int(a * tmp))


def read():
	(a, b) = map(int, input().split())
	return (a, b)

def solve(a, b):
	l = 0
	bb = b
	while bb > 0:
		bb = bb // 10
		l += 1
	if 10 ** l - 1 == b:
		return a * l
	return a * (l - 1)
for i in range(int(input())):
	result = solve(*read())
	print(result)


def solve(a, b):
	cnt = -1
	t = 1
	while t - 1 <= b:
		t *= 10
		cnt += 1
	print(cnt * a)

def main():
	tc = int(input())
	for _ in range(tc):
		(a, b) = [int(x) for x in input().split()]
		solve(a, b)
main()


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	d = len(str(b))
	if d * '9' != str(b):
		d = d - 1
	print(a * d)


def main():
	(a, b) = map(int, input().split())
	k = 0
	if b < 9:
		print(0)
	else:
		b = str(b)
		k = len(str(b))
		if not str(b) == '9' * len(b):
			k -= 1
		print(a * k)
for i in range(int(input())):
	main()


for i in range(int(input())):
	(A, B) = [int(x) for x in input().split()]
	if str(B) != len(str(B)) * str(9):
		print(A * (len(str(B)) - 1))
	else:
		print(A * len(str(B)))


T = int(input())
ans = []
for t in range(T):
	(A, B) = input().split(' ')
	(b, count) = (9, 0)
	l = len(B)
	while len(str(b)) <= l and b <= int(B):
		b = b * 10 + 9
		count += 1
	ans.append(count * int(A))
for a in ans:
	print(a)


T = int(input())
for i in range(0, T):
	l = list(map(int, input().split()))
	(A, B) = (l[0], l[1])
	b_piece = list(str(B))
	if B == int('9' * len(b_piece)):
		result = len(b_piece) * A
	else:
		result = A * (len(b_piece) - 1)
	print(result)


import math
from sys import stdin

def count_pairs(start, end):
	count = 1
	while 10 ** count - 1 <= end:
		count += 1
	return start * (count - 1)

def main():
	first_line = True
	for line in stdin:
		if first_line:
			first_line = False
		else:
			line = line.split(' ')
			print(count_pairs(int(line[0]), int(line[1])))
main()


from math import ceil, sqrt
for _ in range(int(input())):
	mmm = 0
	(a, b) = map(int, input().split())
	m = len(str(b))
	if b > 10 ** m - 2:
		mul = m
	else:
		mul = m - 1
	print(mul * a)


try:
	w = int(input())
	for _ in range(w):
		(x, y) = map(int, input().split())
		e = len(str(y))
		z = 0
		if 10 ** e - 2 < y:
			z += e
		else:
			z += e - 1
		ans = x * z
		print(ans)
except:
	pass


import math
t = int(input())
for _ in range(t):
	x = input().split()
	A = int(x[0])
	B = x[1]
	pow = len(B)
	sum = 0
	if 10 ** pow - 1 <= int(B):
		sum += A
	if pow >= 2:
		sum += A * (pow - 1)
	print(sum)


tc = int(input())
while tc != 0:
	tc -= 1
	cnt = 0
	(a, b) = map(int, input().split())
	temp = b
	while temp > 0:
		cnt += 1
		temp = temp // 10
	for i in range(cnt):
		if b % 10 != 9:
			cnt -= 1
			break
		b = b // 10
	print(cnt * a)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	count = 0
	por = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]
	c = 0
	for j in por:
		if b >= j:
			count += 1
	print(a * count)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	(a, b) = inp()
	ans = 0
	b1 = len(str(b + 1)) - 1
	ans = a * b1
	out(ans)


t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	B += 1
	b_count = 0
	while B >= 10:
		B /= 10
		b_count += 1
	print(b_count * A)


t = int(input())
for i in range(t):
	(a, b) = [int(i) for i in input().split(' ')]
	j = 9
	k = 0
	while j <= b:
		k += 1
		j = j * 10 + 9
	print(a * k)


import sys, itertools, math
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b) = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	s = a * int(math.log10(b))
	if b == int(''.join(['9'] * len(str(b)))):
		s += a
	print(s)


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for _ in range(test):
	(a, b) = multi_int_input()
	n = 9
	count = 0
	while n <= b:
		n = n * 10 + 9
		count += 1
	print(a * count)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = len(str(b))
	print(a * (l - (str(b) != '9' * l)))


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
p = [int('9' * i) for i in range(1, 20)]
while t:
	t -= 1
	(a, b) = I()
	ans = 0
	for i in p:
		if i <= b:
			ans += 1
	print(ans * a)


t = int(input())

def check(a, b):
	k = str(b)
	c = len(str(b)) - 1
	if k == '9' * len(k):
		c += 1
	return a * c
for _ in range(t):
	(a, b) = map(int, input().split())
	print(check(a, b))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(dem, hi) = (0, '9')
	while int(hi) <= b:
		hi += '9'
		dem += 1
	print(a * dem)


import math
testCases = int(input())
for _ in range(testCases):
	(A, B) = map(int, input().split())
	count = 0
	start = 9
	addBy = 9
	while True:
		if start <= B:
			count += 1
			start += addBy * 10
			addBy *= 10
		else:
			break
	print(A * count)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	tmp = b
	c = 0
	while tmp > 0:
		c += 1
		tmp = tmp // 10
	if b == math.pow(10, c) - 1:
		print(a * c)
	else:
		c = c - 1
		print(a * c)


import math as m
Q = int(input())
for i in range(Q):
	(a, b) = map(int, input().split())
	print(a * int(m.log10(b + 1)))


import math
n = int(input())
for _ in range(n):
	nums = [int(x) for x in input().strip().split()]
	b = str(nums[1] + 1)
	print(nums[0] * (len(b) - 1))


def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		x = len(str(b))
		if b == int('9' * x):
			x += 1
		print(a * (x - 1))
main()


x = int(input())
for i in range(x):
	(a, b) = map(int, input().split())
	ans = 0
	k = 9
	while k <= b:
		k = 10 * k + 9
		ans += a
	print(ans)


t = int(input())
while t > 0:
	(A, B) = map(int, input().split())
	B = B + 1
	x = len(str(B)) - 1
	print(A * x)
	t = t - 1


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	k = 0
	b = 9
	chk = True
	while chk:
		n = len(str(b))
		if b + 1 == 10 ** n and b <= B:
			k += 1
			b = int(str(b) + '9')
		else:
			chk = False
	print(k * A)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	lenb = len(str(b))
	if b == 10 ** lenb - 1:
		print(lenb * a)
	else:
		print((lenb - 1) * a)


from math import log10
for case in range(int(input())):
	(A, B) = map(int, input().split())
	nine_type = int(log10(B + 1))
	print(A * nine_type)


import math
t = int(input())
d = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999, 9999, 9999999999, 99999999999, 9999999999999]
for k in range(t):
	(a, b) = list(map(int, input().split()))
	if b in d:
		b += 1
	print((len(str(b)) - 1) * a)


import math
t = int(input())
pika = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999]
for i in range(0, t):
	(A, B) = map(int, input().split())
	a = A
	b = B
	c = 0
	for i in pika:
		if i <= B:
			c = c + 1
	print(A * c)


def solve(a, b):
	c = int('9' * len(str(b)))
	l = len(str(c))
	if b < c:
		return a * (l - 1)
	if b == c:
		return a * l
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(solve(a, b))


t = int(input())
for _ in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	mult = 0
	if 9 <= b and b < 99:
		mult = 1
	elif 99 <= b and b < 999:
		mult = 2
	elif 999 <= b and b < 9999:
		mult = 3
	elif 9999 <= b and b < 99999:
		mult = 4
	elif 99999 <= b and b < 999999:
		mult = 5
	elif 999999 <= b and b < 9999999:
		mult = 6
	elif 9999999 <= b and b < 99999999:
		mult = 7
	elif 99999999 <= b and b < 999999999:
		mult = 8
	elif 999999999 <= b and b < 9999999999:
		mult = 9
	elif 9999999999 <= b and b < 99999999999:
		mult = 10
	print(mult * a)


for u in range(int(input())):
	(a, b) = input().split()
	print(int(a) * (len(str(int(b) + 1)) - 1))


t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	temp = 9
	for i in range(100):
		if temp > b:
			print(a * i)
			break
		temp = temp * 10 + 9


t = int(input())
for kek in range(t):
	(A, B) = map(int, input().split())
	k = 0
	n = 0
	while k <= B:
		k *= 10
		k += 9
		n += 1
	n -= 1
	print(A * n)


t = int(input())
while t > 0:
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])
	temp = b + 1
	c = 0
	while temp >= 10:
		temp //= 10
		c += 1
	print(a * c)
	t -= 1


t = int(input())
p = '99999999999'
for i in range(t):
	(a, b) = map(str, input().split())
	if b == p[:len(b)]:
		print(int(a) * len(b))
	else:
		print(int(a) * (len(b) - 1))


t = int(input())
ans = []
for i in range(t):
	(a, b) = map(int, input().split())
	b = str(b)
	if b == '9' * len(b):
		c = len(b)
	else:
		c = len(b) - 1
	ans.append(c * a)
print(*ans, sep='\n')


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	b = 9
	ans = 0
	while b <= B:
		ans += A
		b = b * 10 + 9
	print(ans)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
import sys
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if b < 9:
		print(0)
		continue
	z = '9'
	ba = []
	while int(z) <= b:
		z = z + '9'
		ba.append(z)
	k = len(ba)
	print(k * a)


from sys import stdin, stdout

def m(a, b, aLetra, bLetra):
	orden = len(bLetra)
	contador = a * (orden - 1)
	if int('9' * orden) <= b:
		contador += a
	return contador

def main():
	resp = ''
	numeros = int(stdin.readline())
	for i in range(numeros):
		linea = stdin.readline().split()
		resp += str(m(int(linea[0]), int(linea[1]), linea[0], linea[1])) + '\n'
	stdout.write(resp)
main()


for i in range(int(input())):
	(a, b) = map(int, input().split())
	n = 0
	while 10 ** n - 1 <= b:
		n += 1
	print(a * (n - 1))


for case in range(int(input())):
	(A, B) = map(int, input().split())
	l = 1
	while int('9' * l) <= B:
		l += 1
	l -= 1
	print(A * l)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	cnt = 0
	x = 1
	while 1:
		x *= 10
		if x - 1 <= b:
			cnt += 1
		else:
			break
	print(cnt * a)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	k = 0
	b += 1
	while b > 0:
		k += 1
		b //= 10
	print(a * (k - 1))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().strip().split())
	b += 1
	answer = a * (len(str(b)) - 1)
	print(answer)


import sys, math
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans = math.floor(math.log(b, 10))
	if b < 10 ** (ans + 1) - 1:
		print(a * ans)
	else:
		print(a * (ans + 1))


t = int(input())
for i in range(t):
	q = input().split()
	a = int(q[0])
	b = q[1]
	l = len(b)
	count = 0
	if int(b) >= 9:
		if b >= str(9) * l:
			count += 1
		print(a * (l - 1 + count))
	else:
		print('0')


from os import path
import sys
from math import ceil, floor, gcd, log
from collections import defaultdict, Counter
maxx = float('inf')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	I = lambda : int(sys.stdin.buffer.readline())
	tup = lambda : map(int, sys.stdin.buffer.readline().split())
	lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
	S = lambda : sys.stdin.readline().replace('\n', '').strip()
	stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
	star = lambda x: print(' '.join(map(str, x)))
else:
	I = lambda : int(sys.stdin.buffer.readline())
	tup = lambda : map(int, sys.stdin.buffer.readline().split())
	lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
	S = lambda : sys.stdin.readline().replace('\n', '').strip()
	stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
	star = lambda x: print(' '.join(map(str, x)))
for _ in range(I()):
	(a, b) = tup()
	cnt = 0
	for i in range(1, 10):
		if 10 ** i - 1 <= b:
			cnt += a
	print(cnt)


t = int(input())
while t:
	t -= 1
	(a, b) = list(map(int, input().split()))
	b = str(b)
	if int(b) >= int('9' * len(b)):
		print(a * len(b))
	else:
		print(a * (len(b) - 1))


import bisect
import heapq
import math
import collections
import sys
import copy
from functools import reduce
import decimal
from io import BytesIO, IOBase
import os
sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
graphDict = collections.defaultdict
queue = collections.deque

class Graphs:

	def __init__(self):
		self.graph = graphDict(list)

	def add_edge(self, u, v):
		self.graph[u].append(v)
		self.graph[v].append(u)

	def dfs_utility(self, nodes, visited_nodes):
		visited_nodes.add(nodes)
		print(nodes, end='')
		for neighbour in self.graph[nodes]:
			if neighbour not in visited_nodes:
				self.dfs_utility(neighbour, visited_nodes)

	def dfs(self, node):
		Visited = set()
		self.dfs_utility(node, Visited)

	def bfs(self, node):
		visited = set()
		if node not in visited:
			queue.append(node)
			visited.add(node)
		while queue:
			parent = queue.popleft()
			print(parent)
			for item in self.graph[parent]:
				if item not in visited:
					queue.append(item)
					visited.add(item)

class Tree:

	def __init__(self, data):
		self.data = data
		self.left = None
		self.right = None

def inorder(node):
	if node:
		inorder(node.left)
		print(node.data)
		inorder(node.right)

def leaf_node_sum(root):
	if root is None:
		return 0
	if root.left is None and root.right is None:
		return root.data
	return leaf_node_sum(root.left) + leaf_node_sum(root.right)

def hight(root):
	if root is None:
		return -1
	if root.left is None and root.right is None:
		return 0
	return max(hight(root.left), hight(root.right)) + 1

def rounding(n):
	return int(decimal.Decimal(f'{n}').to_integral_value())

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def inp():
	return sys.stdin.readline().strip()

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
for _ in range(int(inp())):
	(a, b) = map_inp(int)
	temp = f'{b}'
	if temp.count('9') == len(temp):
		print(a * len(temp))
	else:
		print(a * (len(temp) - 1))


t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	x = 9
	count = 0
	while x <= b:
		count += a
		x = x * 10 + 9
	print(count)


import math

def digit(n):
	num = int(math.log(n, 10) + 1)
	return num

def prod9(n):
	sum = 0
	for i in range(n):
		sum = sum + 9 * pow(10, i)
	return sum
test = int(input())
for i in range(test):
	(a, b) = list(map(int, input().split()))
	temp = 0
	b1 = digit(b)
	if b != prod9(b1):
		b1 = b1 - 1
	print(a * b1)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	nine_counter = 0
	for j in range(1, len(str(b)) + 1):
		if int(str(9) * j) <= b:
			nine_counter += 1
	print(a * nine_counter)


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	(a, b) = list(map(int, input().split()))
	s = ['9'] * len(str(b))
	s = ''.join(s)
	if b == int(s):
		print(a * len(str(b)))
	else:
		print(a * (len(str(b)) - 1))


for t in range(int(input())):
	x = list(map(int, input().split()))
	n = x[0]
	r = x[1]
	c = 0
	s = 0
	for i in range(len(str(r))):
		s = s * 10 + 9
	s1 = s - 9 // 10
	if r == s:
		c = n * len(str(r))
	else:
		c = n * (len(str(r)) - 1)
	print(c)


T = int(input())
for i in range(T):
	(a, b) = input().split()
	b = int(b)
	if b < 9:
		print('0')
	else:
		a = int(a)
		c = 0
		c = a
		x = 9
		x = x * 10 + 9
		while x <= b:
			c = c + a
			x = x * 10 + 9
		print(c)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	k = str(k)
	if all((c == '9' for c in k)):
		print(n * len(k))
	else:
		print(n * (len(k) - 1))


t = int(input())
for i in range(0, t):
	ab = list(map(int, input().split()))
	a = ab[0]
	b = ab[1]
	if b == 9 or b == 99 or b == 999 or (b == 9999) or (b == 99999) or (b == 999999) or (b == 9999999) or (b == 99999999) or (b == 999999999):
		lenb = len(str(b))
	else:
		lenb = len(str(b)) - 1
	x = a * lenb
	print(x)


t = int(input())
s = []
a = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999]
for jnjfn in range(0, t):
	x = input()
	xx = x.split()
	A = int(xx[0])
	B = int(xx[1])
	g = 0
	while B >= a[g]:
		g += 1
	s.append(A * g)
for i in s:
	print(i)


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

def li():
	return list(map(int, sys.stdin.readline().split()))

def num():
	return map(int, sys.stdin.readline().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg

def check(a, b, n):
	if ma.ceil(b / (a + 1)) + a <= n:
		return True
	else:
		return False
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		(a, b) = num()
		ss = 0
		cc = 0
		while ss * 10 + 9 <= b:
			ss = ss * 10 + 9
			cc = cc + 1
		print(a * cc)
solve()


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, m) = [int(x) for x in inp().split()]
	x = len(str(m)) - 1
	if int('9' * (x + 1)) <= m:
		x += 1
	print(x * n)


t = int(input())
for _ in range(t):
	ls = [int(x) for x in input().split()]
	i = 9
	ans = 0
	while i <= ls[1]:
		ans += 1
		i = i * 10 + 9
	print(ans * ls[0])


import math
m = int(input())
for i in range(0, m):
	gg = []
	(a, b) = map(int, input().split(' '))
	bb = len(str(b))
	bbb = int(bb * '9')
	if b == bbb:
		z = bb
	else:
		z = bb - 1
	print(z * a)


t = int(input())
while t:
	t -= 1
	(a, b) = tuple(map(int, input().split()))
	l = len(str(b))
	if str(b) == str(l * '9'):
		print(a * l)
	else:
		print(a * (l - 1))


def log(b):
	l = 0
	while b > 9:
		l += 1
		b //= 10
	return l
for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	print(a * log(b + 1))


def bprocess(n):
	c = 0
	all9 = 1
	for i in n:
		if i != '9':
			all9 = 0
		c += 1
	if all9 == 0:
		c -= 1
	return c
t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	print(a * bprocess(b))


t = int(input())
for j in range(0, t):
	ans = 0
	(A, B) = (int(x) for x in input().split())
	n = B
	count = 0
	flag = True
	while n > 0:
		if n % 10 != 9:
			flag = False
		count = count + 1
		n = n // 10
	if flag:
		ans = count * A
	else:
		ans = (count - 1) * A
	print(ans)


for x in range(int(input())):
	(a, b) = map(int, input().split())
	s = set(str(b))
	if s != {'9'}:
		val = len(str(b)) - 1
	else:
		val = len(str(b))
	print(a * val)


import math
n = int(input())
while n > 0:
	(a, b) = map(int, input().split())
	y = math.floor(math.log10(b + 1))
	print(y * a)
	n -= 1


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	(a, b) = f()
	c = 0
	for i in range(1, 10):
		x = '9' * i
		if int(x) <= b:
			c += 1
	print(a * c)


t = int(input())
for w in range(t):
	(a, b) = (i for i in input().split())
	n2 = len(str(int(b) + 1))
	print(int(a) * (n2 - 1))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	d = len(str(m))
	if m != int('9' * d):
		d -= 1
	print(n * d)


import sys

def answer(A, B):
	ell = len(str(B))
	num_b = ell - 1
	if B >= 10 ** ell - 1:
		num_b += 1
	return A * num_b

def main():
	t = int(input())
	while t:
		(A, B) = [int(i) for i in sys.stdin.readline().split()]
		print(answer(A, B))
		t -= 1
	return
main()


n = int(input())
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	limit = 9
	count = 0
	while b >= limit:
		count += 1
		limit = limit * 10 + 9
	print(a * count)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	num = 9
	cont = 1
	for i in range(9):
		if num > b:
			break
		num = num * 10 + 9
		cont += 1
	print(a * (cont - 1))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = len(str(b))
	temp = int(l * str(9))
	if b < temp:
		l = l - 1
	ans = a * l
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	s = str(b)
	n = len(s) - 1
	if s.count('9') == len(s):
		n += 1
	print(n * a)


t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	s = len(str(B))
	cnt = 0
	for i in range(1, s + 1):
		if 1 <= 10 ** i - 1 <= B:
			cnt += 1
	ans = A * cnt
	print(ans)


import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a < 9 and b < 9:
		print('0')
	else:
		s = int(math.log10(b))
		c = s * a
		if b == pow(10, s + 1) - 1:
			c += a
		print(c)


t = int(input())
for i in range(t):
	(a, b) = input().split(' ')
	flag = 0
	for i in b:
		if i != '9':
			flag = 1
	if flag == 0:
		n = len(b)
	else:
		n = len(b) - 1
	print(int(a) * n)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = input()[:-1].split()
	print(int(a) * (len(b) - 1 + (b == '9' * len(b))))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def f(x, n):
	sum = 1
	for i in range(1, n + 1):
		sum += x ** i / factorial(i)
	return sum

def findn(x, e):
	temp = 2
	while f(x, temp) - f(x, temp - 1) >= e:
		temp += 1
	return temp

def solve():
	(a, b) = sep()
	if b == int('9' * len(str(b))):
		print(len(str(b)) * a)
	else:
		print((len(str(b)) - 1) * a)
testcase(int(inp()))


import sys
from collections import defaultdict
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	n_nines = 0
	itr = 9
	while itr <= b:
		n_nines += 1
		itr = itr * 10 + 9
	print(n_nines * a)


import math
import sys

def listinput():
	return list(map(int, input().split(' ')))

def main():
	answer = ''
	for test in range(int(input())):
		(A, B) = listinput()
		B = str(B)
		amofb = len(B) - 1
		nines = True
		for i in B:
			if i != '9':
				nines = False
		if nines:
			amofb += 1
		answer += str(amofb * A) + '\n'
		pass
	print(answer)
main()


for i in range(int(input())):
	(m, n) = map(int, input().split())
	s = 0
	k = 9
	while 1:
		if n >= k:
			s += 1
			k = k * 10 + 9
		else:
			break
	print(m * s)


def main():
	t = int(input())
	for i in range(t):
		solve()

def solve():
	(a, b) = list(map(int, input().split(' ')))
	count = 0
	number = '9'
	while b >= int(number):
		count += 1
		number += '9'
	print(a * count)
main()


t = int(input())
while t > 0:
	(a, b) = [int(ele) for ele in input().split()]
	s = str(b)
	length = len(s)
	res = '9' * length
	if int(res) > b:
		print(a * (length - 1))
	else:
		print(a * length)
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = b + 1
	if len(str(c)) == len(str(b)) + 1:
		l = len(str(b))
	else:
		l = len(str(b)) - 1
	print(a * l)


t = int(input())
for i in range(t):
	count = 0
	(a, b) = map(int, input().split())
	temp = b
	l = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999]
	while b > 0:
		b = b // 10
		count += 1
	if temp in l:
		print(a * count)
	else:
		print(a * (count - 1))


N = int(input())
for _ in range(N):
	(a, b) = list(map(int, input().split()))
	res = 0
	i = 1
	while 10 ** i - 1 <= b:
		res += a
		i += 1
	print(res)


def a():
	g = [int(i) for i in input().split()]
	A = g[0]
	B = g[1]
	if B <= 8:
		return 0
	else:
		temp = '9'
		count = 0
		while int(temp) <= B:
			count += 1
			temp = temp + '9'
	return A * count
t = int(input())
for i in range(t):
	print(a())


from math import sqrt

def meowmeow321():
	(a, b) = map(int, input().split())
	x = 9
	ans = 0
	while x <= b:
		ans += a
		x = x * 10 + 9
	print(ans)
t = int(input())
for a in range(t):
	meowmeow321()


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()

def sieve(x):
	a = [True] * (x + 1)
	sq = floor(sqrt(x))
	for i in range(3, sq + 1, 2):
		if a[i]:
			for j in range(i * i, x + 1, i):
				a[j] = False
	if x > 1:
		p = [2]
	else:
		p = []
	for i in range(3, x + 1, 2):
		if a[i]:
			p.append(i)
	return p
for _ in range(ii()):
	(a, b) = mi()
	p = 0
	x = 9
	while x <= b:
		p += 1
		x *= 10
		x += 9
	print(a * p)


t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	n = 9
	cnt = 0
	while n <= B:
		cnt += 1
		n = n * 10 + 9
	print(A * cnt)


def solve(a, b):
	return a * (len(str(b + 1)) - 1)
for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	print(solve(a, b))


from sys import stdin
r = stdin.readline

def main():
	cases = int(r())
	for case in range(cases):
		(A, B) = map(int, r().strip().split())
		ans = 0
		b = 9
		i = 1
		while 10 ** i - 1 <= B:
			i += 1
			ans += A
		print(ans)
main()


import io
import os
from collections import Counter, defaultdict, deque

def solve(A, B):
	ans = 0
	for bLen in range(1, 10):
		b = 10 ** bLen - 1
		if len(str(b)) == bLen and b <= B:
			ans += A
	return ans
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(A, B) = [int(x) for x in input().split()]
	ans = solve(A, B)
	print(ans)


from math import log10
t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	cnt = 0
	while 9 * int((cnt + 1) * '1') <= B:
		cnt += 1
	print(A * cnt)


def no_digit(n):
	ans = 0
	while n > 0:
		n //= 10
		ans += 1
	return ans
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	x = no_digit(m)
	if m < 10 ** x - 1:
		x -= 1
	print(n * x)


T = int(input())
for t in range(T):
	(A, B) = map(int, input().split(' '))
	c = 0
	if str(B).count('9') == len(str(B)):
		print(A * len(str(B)))
	else:
		print(A * (len(str(B)) - 1))


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ans = 0
	flag = 0
	curr2 = 0
	curr = str(b)
	for i in range(len(curr)):
		if int(curr[i]) != 9:
			curr2 += len(curr) - 1
			flag = 1
			break
	if flag == 0:
		curr2 += len(curr)
	ans += a * curr2
	print(ans)


import math
t = int(input())
while t > 0:
	t -= 1
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])
	c = 0
	x = 1
	i = 1
	while i <= b:
		if i == math.pow(10, x) - 1:
			c += 1
			i = i + 9 * math.pow(10, x)
			x += 1
		else:
			i += 1
	print(c * a)


t = int(input())
for testcase in range(t):
	(a, b) = map(int, input().split(' '))
	l = len(str(b))
	if not b == int('9' * l):
		l -= 1
	if l != 0:
		print(a * l)
	else:
		print(0)


import math

def solve(A, B):
	lengthOfB = len(str(B))
	b9 = int('9' * lengthOfB)
	numB = lengthOfB if B >= b9 else lengthOfB - 1
	return A * numB
numTestCase = int(input())
for i in range(numTestCase):
	(A, B) = map(int, input().split())
	print(solve(A, B))


for _ in range(int(input())):
	arr = [int(j) for j in input().split()]
	A = arr[0]
	B = arr[1]
	count = 0
	i = 9
	while i <= B:
		count = count + 1
		i = i * 10 + 9
	print(A * count)


def parser():
	while 1:
		data = list(input().split(' '))
		for number in data:
			if len(number) > 0:
				yield number
input_parser = parser()

def get_word():
	global input_parser
	return next(input_parser)

def get_number():
	data = get_word()
	try:
		return int(data)
	except ValueError:
		return float(data)
N = get_number()
for i in range(N):
	a = get_number()
	b = get_number()
	if b % 10 == 9:
		b += 1
	print(a * (len(str(b)) - 1))


t = int(input().strip())
for _ in range(t):
	(A, B) = list(map(int, input().split()))
	n = len(str(B + 1)) - 1
	print(A * n)


testcase = int(input())

def enter():
	rseq = input()
	rseq = rseq.split(' ')
	rseq = list(map(int, rseq))
	return rseq
while testcase:
	numbers = enter()
	a = numbers[1]
	c = 0
	m = 0
	while a != 0:
		k = a % 10
		a = a // 10
		if k != 9:
			m = 1
		c += 1
	if m == 0:
		d = numbers[0] * c
	else:
		d = numbers[0] * (c - 1)
	print(d)
	testcase -= 1


t = int(input())
import math
for i in range(t):
	lis = input().split()
	a = int(lis[0])
	b = lis[1]
	l = len(b)
	b = int(b)
	if b != 10 ** l - 1:
		print(a * (l - 1))
	else:
		print(a * l)


n = int(input())
while n:
	n = n - 1
	t = k = 0
	(x, y) = map(int, input().split())
	while y > 0:
		if y % 10 == 9:
			t = t + 1
		y = int(y / 10)
		k = k + 1
	if t == k:
		print(x * t)
	else:
		print(x * (k - 1))


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	li = len(str(B))
	if B == int(str(9) * li):
		print(A * li)
	else:
		print(A * (li - 1))


def conc(a, b):
	return int(str(a) + str(b))

def count9(num):
	num = str(num)
	x = ''
	if num[0] == '9':
		for i in range(0, len(num)):
			x += '9'
		if num == x:
			return len(num)
		else:
			return len(num) - 1
	else:
		return len(num) - 1
for i in range(0, int(input())):
	x = input()
	y = x.split()
	A = int(y[0])
	B = int(y[1])
	print(A * count9(B))


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	flag = 0
	for y in str(B):
		if y != '9':
			flag = 1
	if flag == 0:
		print(A * len(str(B)))
		continue
	cnt = A * (len(str(B)) - 1)
	print(cnt)


q = int(input())
for i in range(q):
	(a, b) = map(int, input().split())
	if b < 9:
		print(0)
		continue
	else:
		s = str(b)
		flag = s.count('9') == len(s)
		print(a * (len(s) + flag - 1))


t = int(input())
while t:
	(a, b) = map(int, input().split())
	l_b = 0
	n = b
	while n:
		n = n // 10
		l_b += 1
	s = ''
	for i in range(l_b):
		s += '9'
	s = int(s)
	c_b = 0
	if s <= b:
		c_b = l_b
	else:
		c_b = l_b - 1
	print(c_b * a)
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	leng = len(str(b))
	ans = 0
	for i in range(1, leng + 1):
		if 10 ** i - 1 <= b:
			ans += a
	print(ans)


t = int(input())
for i in range(t):
	inp = list(map(int, input().split(' ')))
	a = inp[0]
	b = inp[1]
	digits = 0
	Number = b
	while Number > 0:
		Number = Number // 10
		digits += 1
	num = 0
	for j in range(digits):
		num = num * 10 + 9
	if num > b:
		num = num // 10
		digits -= 1
		ans = a * digits
		print(ans)
	else:
		ans = a * digits
		print(ans)


from math import *
for zz in range(int(input())):
	(A, B) = map(int, input().split())
	ans = 0
	b = 10
	while b / 10 <= B:
		if b - 1 <= B:
			ans += A
		b *= 10
	print(ans)
x = b - 1


x = 0
y = 0
for i in range(int(input())):
	(a, b) = map(int, input().split(' '))
	b = b + 1
	b = str(b)
	x = len(b) - 1
	y = a * x
	print(y)
	a = 0
	b = 0


import sys, os
from math import *
from random import *

class Answer(BaseException):

	def __init__(self, txt):
		self.__text = txt

	def what(self):
		return self.__text

def answer(arg):
	raise Answer

def gcd(a, b: int):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b: int):
	return a * b // gcd(a, b)

def readArr(__type):
	return list(map(__type, input().split()))

def chomp(s: str):
	if s[-1] == '\n':
		s = s[:-1]
	return s

def readFile(name: str):
	f = open(name, 'r')
	r = f.readlines()
	f.close()
	return r

def init_all():
	sys.setrecursionlimit(max(sys.getrecursionlimit(), 500000))

def lower_bound(a, k):
	(l, r) = (0, len(a) - 1)
	while l != r:
		mid = (l + r) // 2
		if a[mid] < k:
			l = mid + 1
		else:
			r = mid
	return l

def upper_bound(a, k):
	(l, r) = (0, len(a) - 1)
	while l + 1 < r:
		mid = (l + r) // 2
		if a[mid] <= k:
			l = mid
		else:
			r = mid - 1
	if a[r] == k:
		return r
	else:
		return l
N = 128
g = [[] for _ in range(N)]
u = [0 for _ in range(N)]
order = []

def dfs(v: int):
	global g, u, order
	u[v] = 1
	for to in g[v]:
		if g[to] == 1:
			raise Exception('Error in task')
		if g[to] == 0:
			dfs(to)
	u[v] = 2
	order.append(v)

def topsort():
	global order, g, u
	for i in range(len(u)):
		if used[i] == 0:
			dfs(i)
	order.reverse()

def solve():
	(A, B) = map(int, input().split())
	ans = 0
	ans = A * int(log10(B + 1))
	print(ans)

def main(argv: list):
	init_all()
	t = int(input())
	for __ in range(t):
		solve()
	return 0
try:
	exit(main(sys.argv))
except Answer as a:
	print(a.what())
	exit(0)
except Exception as e:
	print('An exception occured:', *e.args)
	exit(-1)


for t in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	p = 9
	k = 0
	if b < 9:
		print(0)
	else:
		while True:
			k = p * 10 + 9
			if k > b:
				break
			p = k
		print(a * len(str(p)))


import math
t = int(input())
answers = []
for ti in range(t):
	ints = list(map(int, input().split()))
	(A, B) = (ints[0], ints[1])
	start = '9'
	current = int(start)
	count = 0
	while current <= B:
		count += A
		start += '9'
		current = int(start)
	answers.append(count)
for a in answers:
	print(a)


t = int(input())
while t:
	(a, b) = map(int, input().split())
	count = 0
	for i in range(1, 20):
		if int('9' * i) <= b:
			count += 1
		else:
			break
	print(a * count)
	t -= 1


from sys import stdin
import math
t = int(stdin.readline().rstrip())
while t > 0:
	(a, b) = map(int, stdin.readline().split())
	mi = min(a, b)
	ma = max(a, b)
	s = str(b)
	q = len(s) - 1
	if int('9' * len(s)) == b:
		q += 1
	print(a * q)
	t -= 1


for i in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	z = len(str(y)) - 1
	if len(set(str(y))) == 1 and y % 10 == 9:
		z += 1
	print(x * z)


import sys
import math
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
t = int(input())
for case in range(t):
	(a, b) = map(int, input().split())
	k = len(str(b))
	if str(b) == '9' * k:
		k += 1
	k -= 1
	print(a * k)


def main():
	(a, b) = map(int, input().split())
	if str(b).count('9') == len(str(b)):
		return a * len(str(b))
	return a * (len(str(b)) - 1)
t = int(input())
for _ in range(t):
	print(main())


for _ in range(int(input())):
	(A, B) = list(map(int, input().split()))
	x = 9
	b = 0
	while x <= B:
		b += 1
		x = x * 10 + 9
	print(A * b)


import collections
local = False
if local:
	file = open('A.txt', 'r')

def inp():
	if local:
		return file.readline().rstrip()
	else:
		return input().rstrip()

def ints():
	return [int(_) for _ in inp().split()]
t = int(inp())
for _ in range(t):
	(A, B) = ints()
	bstr = str(B)
	ans = A * (len(bstr) - 1)
	if bstr == '9' * len(bstr):
		ans += A
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	nine = []
	for i in range(1, 11):
		st = str(9) * i
		num = int(st)
		if num <= b:
			nine.append(num)
	print(a * len(nine))


t = int(input())
for x in range(t):
	(a, b) = map(int, input().split())
	l = list(map(int, str(b)))
	n = len(l)
	if str(b) != n * str(9):
		k = n - 1
	elif str(b) == n * str(9):
		k = n
	print(a * k)


import math
m = 1000000007

def fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans % m * (i % m) % m
	return ans

def power_2(n):
	ans = 1
	for i in range(n):
		ans = ans % m * 2 % m
	return ans
for z in range(int(input())):
	(a, b) = input().split()
	if '9' * len(b) == b:
		print(len(b) * int(a))
	else:
		print((len(b) - 1) * int(a))


t = int(input())

def fun(a, b):
	l = len(str(b))
	if str(b) == '9' * l:
		return a * l
	return a * (l - 1)
for _ in range(t):
	(a, b) = map(int, input().strip().split())
	ans2 = fun(a, b)
	print(ans2)


import sys, math, string, bisect
from itertools import *
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().strip()
t = I()
for _ in range(t):
	(n, m) = M()
	x = len(str(m))
	if int(str(len(str(m)) * '9')) > m:
		x -= 1
	print(n * x)


t = int(input())
for i in range(t):
	count = 0
	(a, b) = map(int, input().split())
	n = b
	while n != 0:
		count += 1
		n = n // 10
	st = '9' * count
	val = int(st)
	if b < val:
		count -= 1
	print(a * count)


for _ in range(int(input())):
	(a, b) = map(str, input().split())
	v = len(b)
	if int(b) < 10 ** len(b) - 1:
		v -= 1
	c = 0
	for i in range(1, v + 1):
		c += int(a)
	print(c)


import math
for _ in range(int(input())):
	(a, b) = tuple(map(int, input().split(' ')))
	print(a * math.floor(math.log10(b + 1)))


def f(cad):
	for i in cad:
		if i != '9':
			return len(cad) - 1
	return len(cad)
t = int(input())
for i in range(t):
	(a, b) = map(str, input().split())
	print(int(a) * f(b))


t = int(input())
for _ in range(t):
	(d, e) = map(int, input().split())
	print(d * len(f'{e + 1}') - d)


t = int(input())
while t > 0:
	(A, B) = [int(ele) for ele in input().split()]
	st = str(B)
	n = len(st)
	st = '9' * n
	if int(st) > B:
		print(A * (n - 1))
	else:
		print(A * n)
	t -= 1


import sys
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	(a, b) = mi()
	c = int(math.log(b, 10)) + 1
	print(a * (c - (b < 10 ** c - 1)))


for _ in range(int(input())):
	(a, b) = input().split()
	lb = len(b)
	ctr_b = lb - ('9' * lb != b)
	print(ctr_b * int(a))


for _ in range(int(input())):
	(a, b) = input().split()
	if set(b) == {'9'}:
		b = str(int(b) + 1)
	print(int(a) * (len(b) - 1))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	k = len(f'{b}')
	n = 0
	for j in range(1, k + 1):
		if 10 ** j - 1 <= b:
			n += 1
	print(a * n)


t = int(input())
from math import *
while t > 0:
	t -= 1
	(a, b) = map(int, input().split())
	c = 0
	p = '9'
	while int(p) <= b:
		p += '9'
		c += 1
	print(a * c)


n = int(input())
for case in range(n):
	(a, b) = map(int, input().split())
	(c, d) = (0, 9)
	while d <= b:
		d = d * 10 + 9
		c += 1
	print(a * c)


import sys
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	res = a * (len(str(b + 1)) - 1)
	print(res)


import io
import os
import sys
from atexit import register
import random
import math
import itertools
DEBUG = False
STRESSTEST = False
if not DEBUG:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.stdout = io.BytesIO()
register(lambda : os.write(1, sys.stdout.getvalue()))
tokens = []
tokens_next = 0

def nextStr():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = input().split()
		tokens_next = 0
	tokens_next += 1
	if type(tokens[tokens_next - 1]) == str:
		return tokens[tokens_next - 1]
	return tokens[tokens_next - 1].decode()

def nextInt():
	return int(nextStr())

def nextIntArr(n):
	return [nextInt() for i in range(n)]

def print(*argv, end='\n'):
	for arg in argv:
		sys.stdout.write((str(arg) + ' ').encode())
	sys.stdout.write(end.encode())

def genTestCase():
	l = random.randint(1, 20)
	r = random.randint(1, 20)
	return (l, r)

def bruteforce(a, b):
	res = 0
	for i in range(1, a + 1):
		for j in range(1, b + 1):
			if i * j + i + j == int(''.join(map(str, [i, j]))):
				res += 1
	return res

def doStressTest():
	while True:
		curTest = genTestCase()
		mySoln = solve(*curTest)
		bruteforceSoln = bruteforce(*curTest)
		if mySoln != bruteforceSoln:
			print('### Found case ###')
			print(curTest)
			print(f'{mySoln} should have been: {bruteforceSoln}')
			return

def getNines(x):
	a = [int('9' * i) for i in range(1, 20)]
	end = next((i for i in range(len(a)) if a[i] > x))
	return a[:end]

def solve(a, b):
	return len(getNines(b)) * a
if not DEBUG and STRESSTEST:
	raise Exception('Wrong flags!')
if STRESSTEST:
	doStressTest()
else:
	t = nextInt()
	for _ in range(t):
		print(solve(nextInt(), nextInt()))
sys.stdout.flush()


q = int(input())
for ew in range(q):
	(a, b) = map(int, input().split())
	p = 0
	pi = 0
	while True:
		if p * 10 + 9 <= b:
			p = p * 10 + 9
			pi += 1
		else:
			break
	print(a * pi)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	b_value = len(b) - 1
	if '9' * len(b) == b:
		b_value = len(b)
	ans = int(a) * b_value
	print(ans)


check = [0, 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	count = 0
	for i in range(10):
		if b >= check[i]:
			count = i
		else:
			break
	print(a * count)


import os
import sys
from atexit import register
from io import StringIO
sys.stdout = StringIO()
register(lambda : os.write(1, sys.stdout.getvalue().encode()))
import math
t = int(input())
for _ in range(t):
	(A, B) = [int(k) for k in input().split()]
	print(A * math.floor(math.log10(B + 1)))


num_test_cases = int(input())
for _ in range(num_test_cases):
	(a, b) = list(map(int, input().split(' ')))
	print(a * (len(str(b + 1)) - 1))


t = int(input())
bs = [10, 100, 1000, 10 ** 4, 10 ** 5, 10 ** 6, 10 ** 7, 10 ** 8, 10 ** 9]
for _ in range(t):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	r = 0
	m = 0
	for pos_b in bs:
		if b >= pos_b - 1:
			r += a
		else:
			break
		m += 1
	print(r)


def fun(s):
	d = len(str(s))
	if str(s) == d * '9':
		return d
	return d - 1
for i in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	print(a * fun(b))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	start = 9
	total = 0
	while start <= b:
		total += a
		start = start * 10 + 9
	print(total)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	now = 9
	cnt = 0
	while now <= b:
		cnt += 1
		now = int(str(now) + '9')
	print(cnt * a)


T = int(input())
for _ in range(T):
	(A, B) = input().split()
	k = len(B) - 1
	if 10 ** len(B) - 1 == int(B):
		k += 1
	ans = int(A) * k
	print(ans)


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(a, b) = map(int, stdin.readline().split())
	c = 0
	b += 1
	while b >= 10:
		b //= 10
		c += 1
	stdout.write('{}\n'.format(c * a))


t = int(input())
for i in range(t):
	inp = list(map(int, input().split()))
	a = inp[0]
	b = inp[1]
	k = 1
	while pow(10, k) - 1 <= b:
		k += 1
	k -= 1
	print(a * k)


t = int(input())
for _ in range(t):
	a = input().split()
	b = a[1]
	a = a[0]
	lb = len(b)
	if b == '9' * lb:
		ans = lb * int(a)
	else:
		ans = (lb - 1) * int(a)
	print(ans)


from math import sqrt, ceil
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if set(str(b)) != {'9'}:
		ans = a * (len(str(b)) - 1)
	else:
		ans = a * len(str(b))
	print(ans)


from sys import stdin
for _ in range(int(stdin.readline())):
	(a, b) = map(int, stdin.readline().split())
	cnt = 0
	s = len(str(a))
	s1 = len(str(b))
	for j in range(1, s1 + 1):
		if 10 ** j - 1 <= b:
			cnt += 1
	print(cnt * a)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	dp = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]
	ans = 0
	for i in range(9):
		if dp[i] <= b:
			ans += 1
		else:
			break
	print(a * ans)


t = int(input())
for t1 in range(t):
	ans = 0
	(a, b) = list(map(int, input().split()))
	if b > 9:
		temp = len(str(b)) - 1
		ans += temp
		if str(b) == '9' * (temp + 1):
			ans += 1
		ans *= a
	if b == 9:
		ans += 1
		ans *= a
	print(ans)


for _ in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	y = len(str(b)) - 1
	if str(b) == '9' * (y + 1):
		y += 1
	print(a * y)


t = int(input())
while t > 0:
	(a, b) = input().split()
	if len(b) == b.count('9'):
		print(int(a) * len(b))
	else:
		print(int(a) * (len(b) - 1))
	t -= 1


import math
t = int(input())
for _ in range(t):
	(A, B) = [int(x) for x in input().split()]
	x = list(str(B))
	temp = 0
	if len(set(x)) == 1 and x[0] == '9':
		temp = 1
	x = len(x) - 1 + temp
	print(A * x)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	tot = len(str(b))
	if str(b) == '9' * len(str(b)):
		print(a * tot)
	else:
		tot -= 1
		print(a * tot)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	d = inp()
	for v in range(d):
		(a, b) = inlt()
		d = 9
		c = 0
		while d <= b:
			c += 1
			d = 10 * d + 9
		print(c * a)
main()


T = int(input())
for z in range(T):
	(A, B) = map(int, input().split())
	print(A * (len(str(B + 1)) - 1))


t = int(input())
curr = 9
l = []
while 1:
	if curr > 10 ** 9:
		break
	l.append(curr)
	curr = 10 * curr + 9
for you in range(t):
	lo = input().split()
	a = int(lo[0])
	b = int(lo[1])
	count = 0
	for i in l:
		if i <= b:
			count += 1
	print(count * a)


t = int(input())
for i in range(t):
	b1 = 9
	sum1 = 0
	a = [int(i) for i in input().split()]
	while b1 <= a[1]:
		sum1 += a[0]
		b1 = b1 * 10 + 9
	print(sum1)


def solve():
	(x, y) = map(int, input().split())
	tot = 0
	lol = 9
	while lol <= y:
		tot += x
		lol = lol * 10 + 9
	print(tot)
t = int(input())
for _ in range(t):
	solve()


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
test_count = int(input())
for t in range(test_count):
	(A, B) = invr()
	digits = len(str(B))
	if 10 ** digits - 1 != B:
		digits -= 1
	print(A * digits)


def con(a, b):
	f = 0
	if b < 9:
		return 0
	p = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999]
	for i in range(len(p)):
		if b >= p[i]:
			f = i
		else:
			break
	return a * (f + 1)
t = int(input())
p = []
for i in range(t):
	(a, b) = input().split()
	p.append(con(int(a), int(b)))
for j in range(len(p)):
	print(p[j])


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	print(n * (len(str(m + 1)) - 1))


def pf(B):
	i = len(str(B))
	return i
for tests in range(int(input())):
	(A, B) = list(map(int, input().split()))
	ND = pf(B)
	ans = ND
	if B < 10 ** ND - 1:
		ans -= 1
	ans *= A
	print(ans)


t = int(input())
for n in range(0, t):
	m = input()
	a = int(m.split(' ')[0])
	b = int(m.split(' ')[1])
	l = len(str(b)) - 1
	if len(str(b)) + 1 == len(str(b + 1)):
		l = l + 1
	print(a * l)


from math import log
calc = lambda x, d: x + ceil(d / (x + 1))
for t in range(int(input())):
	(a, b) = map(int, input().split())
	print(a * int(log(b + 1, 10)))


import math
t = int(input())
for k in range(t):
	(A, B) = map(int, input().split())
	if B >= 9:
		ans = len(str(B + 1)) - 1
		print(ans * A)
	else:
		print('0')


t = int(input())
import math
for i in range(t):
	(A, B) = [int(x) for x in input().split()]
	t = math.ceil(math.log(B, 10))
	if 10 ** t - 1 > B:
		t -= 1
	print(t * A)


import math
for i in range(int(input())):
	(a, b) = map(int, input().split())
	digit = math.ceil(math.log10(b + 1))
	if b < int(str('9' * digit)):
		print((digit - 1) * a)
	else:
		print(digit * a)


T = int(input())
a = [0] * T
b = [0] * T
for i in range(T):
	(a[i], b[i]) = map(int, input().split())
for j in range(T):
	B = str(b[j] + 1)
	print((len(B) - 1) * a[j])


import sys
input = sys.stdin.readline
flush = sys.stdout.flush

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	from math import log
	t = iin()
	while t:
		t -= 1
		(A, B) = lin()
		ans = A * int(log(B + 1, 10))
		print(ans)
main()


t = int(input())
for k in range(t):
	(a, b) = map(int, input().split())
	c = 0
	x = 9
	while x <= b:
		c += 1
		x = int(str(x) + '9')
	print(c * a)


import math
numTestCases = int(input())
for _ in range(numTestCases):
	(maxA, maxB) = [int(i) for i in input().split()]
	numPossibleA = maxA
	numPossibleB = int(math.log10(maxB + 1))
	print(numPossibleA * numPossibleB)


t = int(input())
s = [10 ** i - 1 for i in range(1, 18)]
for _ in range(t):
	(a, b) = map(int, input().split())
	c = 0
	for i in s:
		if i <= b:
			c += 1
		else:
			break
	print(a * c)


import math
import os
n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split(' ')))
	if b < 9:
		print(0)
	else:
		x = 9
		c = 1
		while x <= b:
			c += 1
			x = x * 10 + 9
		c -= 1
		print(a * c)


t = int(input())
for test in range(t):
	(a, b) = [int(x) for x in input().split()]
	bb = str(b)
	n = len(bb)
	FLAG = 0
	for i in range(n):
		if bb[i] != '9':
			FLAG = 1
	ans = 0
	if FLAG == 0:
		ans = a * n
	else:
		ans = a * (n - 1)
	print(ans)


import math

def main():
	t = int(input())
	for _ in range(t):
		(a, b) = [int(x) for x in input().split()]
		result = 0
		t = 10
		while b >= t - 1:
			t *= 10
			result += a
		print(result)
main()


from math import ceil, sqrt, log
t = int(input())
for z in range(t):
	(a, b) = map(int, input().split())
	bb = int(log(b, 10))
	if str(b).count('9') == len(str(b)):
		bb += 1
	print(a * bb)


import math
t = int(input())
while t:
	t += -1
	(A, B) = map(int, input().split())
	ln1 = len(str(A))
	ln2 = len(str(B))
	temp2 = int(ln2 * '9')
	if temp2 > B:
		ln2 -= 1
	print(A * ln2)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	l = len(str(b))
	check = '9' * l
	if int(check) == b:
		pass
	else:
		l = l - 1
	res = a * l
	print(res)


import sys

def read_in():
	stri = sys.stdin.readline()
	return stri.strip()

def from_str_to_list(stri):
	res_List = []
	for i in stri.split():
		res_List.append(int(i))
	return res_List

def main():
	t = int(read_in())
	k = 0
	for i in range(t):
		data = from_str_to_list(read_in())
		A = data[0]
		B = data[1]
		while 10 ** k - 1 <= B:
			k += 1
		k -= 1
		print(A * k)
		k = 0
	return
main()


n = int(input())
res = list()
for i in range(n):
	A = [int(i) for i in input().split()]
	if str(A[1]) == '9' * len(str(A[1])):
		res.append(str(A[0] * len(str(A[1]))))
	else:
		res.append(str(A[0] * (len(str(A[1])) - 1)))
print('\n'.join(res))


import math
t = int(input())
while t:
	(a, b) = map(int, input().split(' '))
	b1 = b
	c = 0
	while b != 0:
		c = c + 1
		b = b // 10
	if b1 == math.pow(10, c) - 1:
		print(a * c)
	else:
		print(a * (c - 1))
	t = t - 1


import math

def intinputlist():
	l = [int(x) for x in input().split()]
	return l

def printlist(l):
	print(*l)

def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def countd(n):
	if n > 0:
		digits = int(math.log10(n)) + 1
	elif n == 0:
		digits = 1
	else:
		digits = int(math.log10(-n)) + 2
	return digits
t = int(input())
while t:
	(a, b) = map(int, input().split())
	c = 0
	if b == 10 ** len(str(b)) - 1:
		print(countd(b) * a)
	else:
		print((countd(b) - 1) * a)
	t -= 1


for tc in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	x = 9
	while x <= b:
		ans += 1
		x = int(str(x) + str(9))
	print(a * ans)


f = lambda a, b: a * b + a + b
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	i = 1
	while 1:
		n = int(str('9' * i))
		if n > b:
			break
		i += 1
		c += a
	print(c)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = str(b)
	l = len(s)
	ans = l - 1
	sm = sum(map(int, str(b)))
	if sm == 9 * l:
		ans += 1
	print(ans * a)


import math
t = int(input())
for i in range(t):
	flag = True
	(a, b) = map(int, input().split())
	res = len(str(b)) - 1
	for j in str(b):
		if j != '9':
			flag = False
			break
	if flag:
		res += 1
	print(res * a)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
yy = lambda : print('YES')
nn = lambda : print('NO')
from math import log10, log2, ceil, factorial as fac, gcd, inf
for _ in range(t()):
	(n, k) = ll()
	c = 0
	x = '9'
	while int(x) <= k:
		c += 1
		x += '9'
	print(c * n)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	print(n * (len(str(m + 1)) - 1))


import math
for i in range(0, int(input())):
	(A, B) = map(str, input().split(' '))
	x = int(A)
	y = len(B)
	y1 = int(B)
	if y1 != pow(10, y) - 1:
		y -= 1
	print(x * y)


def MemeProblem():
	for _ in range(int(input())):
		(a, b) = list(map(int, input().split(' ')))
		t = 0
		c = 0
		while t * 10 + 9 <= b:
			t = t * 10 + 9
			c += 1
		print(a * c)
MemeProblem()


t = int(input())
for tt in range(t):
	(a, b) = list(map(int, input().split()))
	mmx = b
	itr = 0
	base = 0
	while base <= mmx:
		itr += 1
		base = int('9' * itr)
	print(a * (itr - 1))


def main():
	(a, b) = map(int, input().split())
	mx = b
	mx = str(mx)
	n = len(mx)
	for i in range(len(mx)):
		if mx[i] != '9':
			n -= 1
			break
	print(a * n)

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


t = int(input())
for i in range(0, t):
	n = 0
	(a, b) = [int(x) for x in input().split()]
	if a < 9 and b < 9:
		print(0)
	else:
		b = b + 1
		while b != 0:
			b = b // 10
			n = n + 1
		print(a * (n - 1))


t = int(input())
dp = [0] * 10
for i in range(1, 10):
	dp[i] = 10 ** i

def dig(b):
	co = 0
	while b != 0:
		b //= 10
		co += 1
	return co
for _ in range(t):
	(a, b) = map(int, input().split())
	digitb = dig(b)
	if b != 10 ** digitb - 1:
		digitb -= 1
	print(a * digitb)


for _ in range(int(input())):
	(A, B) = input().split()
	l = len(B)
	l1 = '9' * l
	if int(B) < int(l1):
		print(int(A) * (l - 1))
	else:
		print(int(A) * l)


import os
import sys
from io import BytesIO, IOBase

def solution(A, B):
	if B >= 9:
		nine = '9'
		while int(nine + '9') <= B:
			nine += '9'
		write(A * len(nine))
	else:
		write(0)

def main():
	for _ in range(r_int()):
		(A, B) = r_array()
		solution(A, B)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())

def w_array(arr):
	for x in arr:
		write(x, end=' ')
	write()
main()


import math
t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	n1 = len(str(B))
	for i in str(B):
		if i != '9':
			n1 = n1 - 1
			break
	print(A * n1)


def num():
	return int(input())

def line():
	return map(int, input().split())
from itertools import repeat
t = num()
for _ in repeat(None, t):
	(A, B) = line()
	print(A * (len(str(B)) - 1 + all((c == '9' for c in str(B)))))


t = int(input().strip())

def find_digit(n):
	ans = 0
	start = 9
	while n >= start:
		ans += 1
		start = int(str(start) + '9')
	return ans
for _ in range(t):
	(a, b) = map(int, input().strip().split())
	print(a * find_digit(b))


def solve():
	(a, b) = map(int, input().split())
	lb = len(str(b))
	if b == int('9' * lb):
		return a * lb
	else:
		return a * (lb - 1)
[print(solve()) for _ in range(int(input()))]


def meme_problem(a, b):
	length = len(str(b))
	compare = ['9'] * length
	compare_num = int(''.join(compare))
	if b == compare_num:
		return a * length
	else:
		return a * (length - 1)
test = int(input())
for x in range(test):
	(q, y) = list(map(int, input().split()))
	print(meme_problem(q, y))


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	if B == 10 ** len(str(B)) - 1:
		ans = len(str(B))
	else:
		ans = len(str(B)) - 1
	print(A * ans)


t = int(input())
for _ in range(t):
	(A, B) = map(int, input().split())
	k = 9
	c = 0
	while True:
		if k <= B:
			c += 1
			k = int(str(k) + '9')
		else:
			break
	print(c * A)


T = int(input())
from math import log
for t in range(T):
	(A, B) = [int(x) for x in input().split()]
	ans = A * int(log(B, 10))
	if log(B + 1, 10) == int(log(B + 1, 10)):
		ans += A
	print(ans)


T = int(input())
for i in range(T):
	data = input().split()
	a = int(data[0])
	b = int(data[1])
	x = len(str(b)) - 1
	if len(str(b + 1)) > len(str(b)):
		x += 1
	print(a * x)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(r, z) = ('9', 0)
	while b >= int(r):
		z += a
		r += '9'
	print(z)


def meme(a, b):
	l = len(str(b))
	if int('9' * l) > b:
		l -= 1
	return a * l
t = int(input())
array = []
for i in range(t):
	array.append(list(map(int, input().split(' '))))
for x in array:
	print(meme(*x))


t = int(input())
while t:
	(a, b) = map(int, input().split())
	b = b + 1
	x = len(str(b))
	count = a * (x - 1)
	print(count)
	t -= 1


def li():
	return list(map(int, input().split()))

def ii():
	return int(input())
testcases = int(input())
for t in range(testcases):
	(a, b) = li()
	noOfDigitsInB = len(str(b))
	if b < 10 ** noOfDigitsInB - 1:
		noOfDigitsInB -= 1
	print(a * noOfDigitsInB)


l = int(input())
for i in range(l):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	v = b
	count = -1
	while v:
		count += 1
		v = v // 10
	if b + 1 == pow(10, count + 1):
		count += 1
	print(count * a)


t = eval(input())
while t:
	t -= 1
	(a, b) = input().split()
	bl = len(b)
	b2 = ''
	for i in range(1, bl + 1):
		b2 += '9'
	lens = 0
	if int(b) == int(b2):
		lens = len(b)
	else:
		lens = len(b) - 1
	print(lens * int(a))


tests = int(input())
for te in range(tests):
	(a, b) = list(map(int, input().split()))
	n = 9
	answer = 0
	while n <= b:
		answer += a
		n = n * 10 + 9
	print(answer)


from collections import defaultdict as dc
from collections import deque as dq
import bisect
import sys
import math
mod = 10 ** 9 + 7

def bs(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def binarysearchforsolvingeqautions(a, i, l, r):
	while 1:
		mid = (l + r) / 2
		(p, q) = force(a, mid, i)
		if abs(p - q) < 1e-13:
			return mid
		elif p > q:
			l = mid
		else:
			r = mid

def bs(z, x, n):
	l = 0
	r = len(z) - 1
	ans = -1
	mk = n
	while l < r:
		mid = (l + r) // 2
		if lcm(z[mid], x, n):
			if mk > max(z[mid], x):
				mk = max(z[mid], x)
				ans = z[mid]
			r = mid - 1
		else:
			l = mid + 1
	return ans

def digit(n):
	a = 0
	while n > 0:
		z = n % 10
		n = n // 10
		a += 1
	return a

def inp():
	p = int(input())
	return p

def line():
	p = list(map(int, input().split()))
	return p

def lcm(a, b):
	c = 0
	for i in range(1, a + 1):
		for j in range(1, b + 1):
			p = str(i)
			q = str(j)
			z = i * j + i + j
			if z == int(p + q):
				c += 1
				if q != '9' and q != '99':
					print(p, q, z)
	print(c)
for _ in range(inp()):
	(a, b) = line()
	if b < 9:
		print(0)
	else:
		z = digit(b)
		s = '9' * z
		if b < int(s):
			z = z - 1
		print(a * z)


def solve(A, B):
	second = 9
	ans = 0
	while second <= B:
		ans += A
		second = second * 10 + 9
	print(ans)
t = int(input())
for _ in range(t):
	solve(*map(int, input().split()))


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	ans = 0
	cur = 10
	while b >= cur - 1:
		ans += a
		cur *= 10
	print(ans)


import math
for _ in range(int(input())):
	count = 0
	(A, B) = map(int, input().split())
	l = int(math.log10(B)) + 1
	for b in range(1, l + 1):
		str = ''
		for k in range(0, b):
			str += '9'
		num = int(str)
		if num <= B:
			if num + 1 == int(pow(10, b)):
				count += 1
	print(count * A)