#include <bits/stdc++.h>
int main() {
  int t;
  int A, B;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &A, &B);
    int i = 9, c = 0;
    while (i <= B) {
      c++;
      i = (i * 10) + 9;
    }
    printf("%lld\n", (A * 1LL * c));
  }
}
