#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long A, B;
    cin >> A >> B;
    long long hb = (floor(log10(B + 1)) == log10(B + 1)) ? (floor(log10(B)) + 1)
                                                         : floor(log10(B));
    cout << hb * A << endl;
  }
  return 0;
}
