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).
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int fib(long long int n) {
  if (n == 0 || n == 1)
    return 1;
  else {
    long long int arr[n + 1];
    arr[0] = 0;
    arr[1] = 1;
    for (long long int i = 2; i <= n; i++) {
      arr[i] = arr[i - 1] + arr[i - 2];
    }
    return arr[n];
  }
}
long long int mpow(long long int base, long long int exp) {
  base %= 1000000007;
  long long int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long int)result * base) % 1000000007;
    base = ((long long int)base * base) % 1000000007;
    exp >>= 1;
  }
  return result;
}
long long int mpow2(long long int base, long long int exp) {
  base %= 998244353;
  long long int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long int)result * base) % 998244353;
    base = ((long long int)base * base) % 998244353;
    exp >>= 1;
  }
  return result;
}
long long int is_prime(long long int a) {
  long long int i;
  if (a == 2 || a == 3)
    return 1;
  else
    for (i = 2; i * i <= a; i++) {
      if (a % i == 0) return 0;
    }
  return 1;
}
long long int dign(long long int n) { return floor(log10(n)) + 1; }
long long int multiply(long long int x, long long int res[],
                       long long int res_size);
long long int factorial(long long int n) {
  long long int res[500];
  res[0] = 1;
  long long int res_size = 1;
  for (long long int x = 2; x <= n; x++) res_size = multiply(x, res, res_size);
  for (long long int i = res_size - 1; i >= 0; i--) cout << res[i];
}
long long int multiply(long long int x, long long int res[],
                       long long int res_size) {
  long long int carry = 0;
  for (long long int i = 0; i < res_size; i++) {
    long long int prod = res[i] * x + carry;
    res[i] = prod % 10;
    carry = prod / 10;
  }
  while (carry) {
    res[res_size] = carry % 10;
    carry = carry / 10;
    res_size++;
  }
  return res_size;
}
long long int binsearch(long long int arr[], long long int l, long long int r,
                        long long int no) {
  while (l <= r) {
    long long int mid = (l + r) / 2;
    if (arr[mid] == no)
      return mid;
    else if (arr[mid] < no)
      l = mid + 1;
    else
      r = mid - 1;
  }
  return -1;
}
string sortString(string &str) {
  long long int i = 0, j = 0, k = 0;
  long long int charCount[26] = {0};
  for (long long int i = 0; i < str.length(); i++) charCount[str[i] - 'a']++;
  for (long long int i = 0; i < 26; i++) {
    for (long long int j = 0; j < charCount[i]; j++) {
      str[k++] = char('a' + i);
    }
  }
  return str;
}
string findSum(string str1, string str2) {
  if (str1.length() > str2.length()) swap(str1, str2);
  string str = "";
  long long int n1 = str1.length(), n2 = str2.length();
  long long int diff = n2 - n1;
  long long int carry = 0;
  for (long long int i = n1 - 1; i >= 0; i--) {
    long long int sum = ((str1[i] - '0') + (str2[i + diff] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  for (long long int i = n2 - n1 - 1; i >= 0; i--) {
    int sum = ((str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  if (carry) str.push_back(carry + '0');
  reverse(str.begin(), str.end());
  return str;
}
const long long int N = 2e5 + 5;
bool vis[N];
vector<long long int> adj[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i = 0, j = 0;
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (b < 9) cout << 0;
    if (b >= 9 && b < 99) cout << a * 1;
    if (b >= 99 && b < 999) cout << a * 2;
    if (b >= 999 && b < 9999) cout << a * 3;
    if (b >= 9999 && b < 99999) cout << a * 4;
    if (b >= 99999 && b < 999999) cout << a * 5;
    if (b >= 999999 && b < 9999999) cout << a * 6;
    if (b >= 9999999 && b < 99999999) cout << a * 7;
    if (b >= 99999999 && b < 999999999) cout << a * 8;
    if (b >= 999999999 && b < 9999999999) cout << a * 9;
    cout << '\n';
  }
}
