#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
long long dig(long long x) {
  int cnt = 1;
  while (x) {
    cnt *= 10;
    x /= 10;
  }
  return cnt;
}
long long cal(long long x) {
  long long cnt = 0;
  for (long long st = 9; st <= x; st = st * 10 + 9) cnt++;
  return cnt;
}
int main() {
  long long t, A, B;
  cin >> t;
  while (t--) {
    cin >> A >> B;
    cout << cal(B) * A << endl;
  }
  return 0;
}
