#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    b++;
    long int dig = -1;
    while (b != 0) {
      b /= 10;
      dig++;
    }
    cout << a * dig << endl;
  }
}
