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