Yet Another Meme Problem

You are given two integers A A A and B B B, calculate the number of pairs ( a , b ) (a,b) (a,b) such that 1 ≤ a ≤ A , 1 ≤ b ≤ B 1≤a≤A, 1≤b≤B 1aA,1bB, and the equation a ⋅ b + a + b = c o n c ( a , b ) a⋅b+a+b=conc(a,b) ab+a+b=conc(a,b) is true; c o n c ( a , b ) conc(a,b) conc(a,b) is the concatenation of a a a and b b b (for example, c o n c ( 12 , 23 ) = 1223 conc(12,23)=1223 conc(12,23)=1223, c o n c ( 100 , 11 ) = 10011 conc(100,11)=10011 conc(100,11)=10011). a and b should not contain leading zeroes.

Input

The first line contains t ( 1 ≤ t ≤ 100 ) t (1≤t≤100) t(1t100) — the number of test cases.

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

Output

Print one integer — the number of pairs ( a , b ) (a,b) (a,b) such that 1 ≤ a ≤ A , 1 ≤ b ≤ B 1≤a≤A, 1≤b≤B 1aA,1bB, and the equation a ⋅ b + a + b = c o n c ( a , b ) a⋅b+a+b=conc(a,b) ab+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 ) a=1, b=9 (1+9+1⋅9=19) a=1,b=9(1+9+19=19).

#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
ll A,B;
ll b[15];
int main() {
    
    
    ll c = 1;
    for (int i = 1; i <= 10; i++) {
    
    
        c = c * 10;
        b[i] = c - 1;
    }
    int _;
    scanf("%d",&_);
    while (_--) {
    
    
        scanf("%lld%lld", &A, &B);
        int i = 1;
        while (b[i] <= B) {
    
    
            i++;
        }
        printf("%lld\n", A * (i - 1));
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43601103/article/details/112542832