#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long int> v;
  v.push_back(9);
  v.push_back(99);
  v.push_back(999);
  v.push_back(9999);
  v.push_back(99999);
  v.push_back(999999);
  v.push_back(9999999);
  v.push_back(99999999);
  v.push_back(999999999);
  long long int test;
  cin >> test;
  while (test--) {
    long long int a, b, x = 0, i;
    cin >> a >> b;
    for (i = 0; i < 9; i++) {
      if (b >= v[i]) {
        x++;
      } else {
        break;
      }
    }
    cout << a * x << endl;
  }
}
