#include <bits/stdc++.h>
using namespace std;
long long powermodm(long long x, long long n, long long M) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long ans = 0;
    long long start = 9;
    while (b >= start) {
      ans++;
      start *= 10;
      start += 9;
    }
    cout << a * ans << '\n';
  }
  return 0;
}
