#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    long long a, b;
    cin >> a >> b;
    vector<long long int> v;
    v.push_back(9);
    v.push_back(99);
    v.push_back(999);
    v.push_back(9999);
    v.push_back(99999);
    v.push_back(999999);
    v.push_back(9999999);
    v.push_back(99999999);
    v.push_back(999999999);
    v.push_back(9999999999);
    long long c = 0;
    for (auto u : v) {
      if (b < u) {
        break;
      }
      c++;
    }
    cout << a * c << '\n';
  }
  return 0;
}
