#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    long long int ans;
    int j = floor(log10(b + 1));
    ans = a * j;
    cout << ans << "\n";
  }
}
