#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int B[] = {9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    cout << ((ll)a * (ll)(upper_bound(B, B + 9, b) - B)) << "\n";
  }
  return 0;
}
