#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    long long int count = 0;
    long long int temp = 9;
    while (b >= temp) {
      count++;
      temp = temp * 10 + 9;
    }
    cout << a * count << "\n";
  }
}
