#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(NULL));
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    long long A, B;
    cin >> A >> B;
    long long total = 0;
    for (long long x = 9; x <= B; x = 10 * x + 9) total += A;
    cout << total << '\n';
  }
  return 0;
}
