#include <bits/stdc++.h>
using namespace std;
long long T;
bool check(long long a, long long b) {
  long long x = a * b + a + b;
  long long t = b;
  long long len = 0;
  while (t) {
    len++;
    t /= 10;
  }
  for (long long i = 0; i < len; i++) {
    a *= 10;
  }
  long long y = a + b;
  return x == y;
}
long long A[12] = {9ll,      99ll,      999ll,      9999ll,      99999ll,
                   999999ll, 9999999ll, 99999999ll, 999999999ll, 9999999999ll};
signed main() {
  scanf("%lld", &T);
  long long a, b, c;
  while (T--) {
    scanf("%lld%lld", &a, &b);
    for (long long i = 0; i < 10; i++) {
      if (b < A[i]) {
        c = i;
        break;
      }
    }
    cout << a * c << '\n';
  }
}
