#include <bits/stdc++.h>
using namespace std;
int t;
long long a, b;
int digits(int x) {
  int d = 0;
  while (x > 0) {
    x /= 10;
    d++;
  }
  return d;
}
int main() {
  double time = clock();
  cin >> t;
  while (t--) {
    cin >> a >> b;
    cout << a * (digits(b + 1) - 1) << endl;
  }
  cerr << "### Time: " << (clock() - time) / CLOCKS_PER_SEC * 1000 << " ms ###"
       << endl;
  return 0;
}
