#include <bits/stdc++.h>
using namespace std;
long long int countDigit(long long int n) {
  long long int count = 0;
  while (n != 0) {
    n = n / 10;
    ++count;
  }
  return count;
}
bool isPower(long long int x, long long int y) {
  if (x == 1) return (y == 1);
  long long int pow = 1;
  while (pow < y) pow *= x;
  return (pow == y);
}
int main() {
  long long int t;
  cin >> t;
  for (long long int i = 0; i < t; i++) {
    long long int A, B;
    cin >> A >> B;
    long long int cnt = countDigit(B);
    if (isPower(10, B + 1))
      cout << A * cnt << endl;
    else
      cout << A * (cnt - 1) << endl;
  }
}
