#include <bits/stdc++.h>
long long int P(int base, int exp) {
  long long int n = 1;
  int i;
  for (i = 1; i <= exp; i++) n *= base;
  return n;
}
int digitnum(long long int num) {
  int d, c = 0;
  long long int temp;
  temp = num;
  do {
    d = temp % 10;
    temp /= 10;
    c++;
  } while (temp);
  return c;
}
int main() {
  int t, i, dnumB, r;
  long long int A, B, R[100] = {0};
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    scanf("%lld%lld", &A, &B);
    dnumB = digitnum(B);
    r = dnumB;
    if (P(10, dnumB) - 1 == B) {
      R[i] = A * r;
    } else if (P(10, dnumB) - 1 > B) {
      do {
        r--;
      } while (P(10, r) - 1 > B);
      if (r == 0)
        R[i] = 0;
      else {
        R[i] = A * r;
      }
    }
  }
  for (i = 0; i < t; i++) printf("\n%lld", R[i]);
  return 0;
}
