#include <bits/stdc++.h>
using namespace std;
int t;
int main() {
  scanf("%d", &t);
  while (t--) {
    long long A, B;
    long long cnt = 0;
    scanf("%lld%lld", &A, &B);
    for (long long b = 9; b <= B; b = (b + 1) * 10 - 1) cnt++;
    printf("%lld\n", cnt * A);
  }
  return 0;
}
