#include <bits/stdc++.h>
using namespace std;
int main() {
  int temp = 0, j = 0;
  cin >> temp;
  for (j = 0; j < temp; j++) {
    long long int a, b;
    cin >> a >> b;
    long long int k[10] = {0};
    int i = 0, t = 1;
    k[1] = 9;
    for (i = 2; i <= 9; i++) {
      k[i] = (k[i - 1] + 9 * pow(10, t));
      t++;
    }
    t = 0;
    for (i = 1; i <= 9; i++) {
      if (k[i] <= b) t++;
    }
    cout << a * t << "\n";
  }
  return 0;
}
