#include <bits/stdc++.h>
using namespace std;
int countDigit(long long n) {
  int count = 0;
  while (n != 0) {
    n = n / 10;
    ++count;
  }
  return count;
}
int main() {
  int t, z;
  cin >> t;
  for (z = 0; z < t; z++) {
    long long int a, b, m, y, n;
    cin >> a >> b;
    m = countDigit(b);
    y = b;
    y++;
    n = countDigit(y);
    if (m != n)
      cout << (n - 1) * a << "\n";
    else if (m > 1)
      cout << (m - 1) * a << "\n";
    else
      cout << "0"
           << "\n";
  }
  return 0;
}
