#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int A, B, ct = 0;
    cin >> A >> B;
    bool flag = 1;
    while (B) {
      if (B % 10 != 9) flag = 0;
      B /= 10;
      ct++;
    }
    if (flag)
      cout << A * ct << endl;
    else
      cout << A * (ct - 1) << endl;
  }
}
