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