#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int modulo(long long int a, long long int b) {
  long long int r = a % b;
  return r < 0 ? r + b : r;
}
long long int longrem(string k, long long int n) {
  int now = 0;
  for (int i = 0; i < k.size(); i++) {
    now = (now * 10) % n;
    now = (now + k[i] - '0') % n;
  }
  return now;
}
long long int ncr(long long int n, long long int k) {
  long long int res = 1;
  if (k > n - k) k = n - k;
  for (long long int i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
long long int binaryToDecimal(long long int n) {
  long long int num = n;
  long long int dec_value = 0;
  long long int base = 1;
  long long int temp = num;
  while (temp) {
    long long int last_digit = temp % 10;
    temp = temp / 10;
    dec_value += last_digit * base;
    base = base * 2;
  }
  return dec_value;
}
void decToBinary(int n) {
  int binaryNum[32];
  int i = 0;
  while (n > 0) {
    binaryNum[i] = n % 2;
    n = n / 2;
    i++;
  }
  for (int j = i - 1; j >= 0; j--) cout << binaryNum[j];
}
long long int prime(long long int n) {
  long long int flag = 0;
  if (n == 1 || n == 2) {
    flag = 0;
  } else {
    if (n % 2 == 0)
      flag = 1;
    else {
      long long int i = 3;
      while (i <= sqrt(n) && flag == 0) {
        if (n % i == 0) flag = 1;
        i = i + 3;
      }
    }
  }
  return flag;
}
long long int ispal(string str, string s) {
  long long int flag = 0;
  reverse(str.begin(), str.end());
  if (str == s) {
    flag = 1;
  }
  return flag;
}
long long int ispalself(string str) {
  long long int flag = 0;
  string s = str;
  reverse(str.begin(), str.end());
  if (str == s) {
    flag = 1;
  }
  return flag;
}
long long int nod(long long int a) {
  long long int d = 0;
  while (a > 0) {
    d++;
    a = a / 10;
  }
  return d;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int i, j, n, m, cnt = 0, d, k;
    cin >> n >> m;
    j = nod(m);
    k = j;
    d = 0;
    while (j--) {
      d = (d * 10) + 9;
    }
    if (m < d) {
      k--;
    }
    cnt = n * k;
    cout << cnt << "\n";
  }
}
