#include <bits/stdc++.h>
using namespace std;
long long int fun(long long int n) {
  long long int count = 0;
  while (n > 0) {
    n /= 10;
    count += 1;
  }
  return count;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    cout << a * (fun(b + 1) - 1) << "\n";
  }
}
