#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b, c, d;
    int e = 0;
    bool ok = true;
    cin >> a >> b;
    c = a;
    d = b;
    while (d != 0) {
      e++;
      if (d % 10 != 9) ok = false;
      d = d / 10;
    }
    long long q = max(0, e - 1);
    (ok) ? cout << c * e << endl : cout << c * q << endl;
  }
  return 0;
}
