#include <bits/stdc++.h>
using namespace std;
long long gao(long long a, long long b) {
  long long c = 9;
  long long ans = 0;
  while (b >= c) {
    ans++;
    c *= 10;
    c += 9;
  }
  ans *= a;
  return ans;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    long long a, b;
    long long c = 9;
    long long ans = 0;
    cin >> a >> b;
    cout << gao(a, b) << endl;
  }
  return 0;
}
