#include <bits/stdc++.h>
unsigned concat(unsigned long x, unsigned long y) {
  unsigned long pow = 10;
  while (y >= pow) pow *= 10;
  return x * pow + y;
}
int main(int argc, char* argv[]) {
  int testCases;
  scanf("%d", &testCases);
  unsigned long long A, B;
  int i;
  for (i = 0; i < testCases; i++) {
    scanf("%llu %llu", &A, &B);
    printf("%llu\n", A * (unsigned long long)floor(log10((B + 1))));
  }
}
