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