#include <bits/stdc++.h>
using namespace std;
long long n, A, B;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  while (n--) {
    cin >> A >> B;
    cout << A * (long long)log10(B + 1) << endl;
  }
}
