#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int k = 0; k < t; ++k) {
    long long int a, b, s = 0;
    cin >> a >> b;
    cout << a * (long long int)(log10(b + 1)) << "\n";
  }
  return 0;
}
