Try guessing the statement from this picture <http://tiny.cc/ogyoiz>.

You are given two integers A and B, calculate the number of pairs (a, b) such that 1 ≤ a ≤ A, 1 ≤ b ≤ B, and the equation a ⋅ 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 ≤ t ≤ 100) — the number of test cases.

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

Output

Print one integer — the number of pairs (a, b) such that 1 ≤ a ≤ A, 1 ≤ b ≤ B, and the equation a ⋅ 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 ⋅ 9 = 19).
import io
import os
import sys
from atexit import register
import random
import math
import itertools

##################################### Flags          #####################################
# DEBUG = True
DEBUG = False
STRESSTEST = False
# STRESSTEST = True

##################################### IO             #####################################

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())


##################################### Helper Methods #####################################
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


##################################### Driver         #####################################

if __name__ == "__main__":
    if not DEBUG and STRESSTEST:
        raise Exception('Wrong flags!')

    if STRESSTEST:
        doStressTest()
    else:
        ### Read input here
        t = nextInt()
        for _ in range(t):
            print(solve(nextInt(), nextInt()))

    sys.stdout.flush()