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