#include <bits/stdc++.h>
using namespace std;
int lgg(int A) {
  int cnt = 0;
  while (A > 0) {
    A = A / 10;
    cnt++;
  }
  return cnt;
}
int main() {
  long long a, cnt = 0, b, T;
  cin >> T;
  for (long long k = 0; k < T; k++) {
    cin >> a >> b;
    cout << (lgg(b + 1) - 1) * a << endl;
  }
}
