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