#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, a, b;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    long long cp = b, cnt = 0;
    bool ok = 0;
    cp++;
    while (cp) {
      cnt++;
      cp /= 10;
    }
    cnt--;
    cout << a * cnt << "\n";
  }
  return 0;
}
