#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, a, l, b, n = 9;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    n = 9;
    l = to_string(b).length();
    for (int i = 0; i < l - 1; ++i) n = n * 10 + 9;
    if (b == n)
      cout << a * l << '\n';
    else
      cout << a * (l - 1) << '\n';
  }
}
