#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long long int pw[10];
  pw[0] = 1;
  for (int i = 1; i <= 10; i++) pw[i] = pw[i - 1] * 10;
  while (t--) {
    long long int A, B;
    cin >> A >> B;
    long long int n = 0;
    long long int z = B;
    while (z) {
      n++;
      z /= 10;
    }
    if (pw[n] - 1 == B)
      cout << n * A << endl;
    else
      cout << (n - 1) * A << endl;
  }
}
