#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 count = 0;
    long long int x = 9;
    while (x <= b) count++, x = x * 10 + 9;
    cout << a * count << endl;
  }
}
