#include <bits/stdc++.h>
using namespace std;
int t, A, B;
int getNrc(int x) {
  int ret = 0;
  while (x) {
    ret++;
    x /= 10;
  }
  return ret;
}
bool doar9(int x) {
  while (x) {
    if (x % 10 != 9) return 0;
    x /= 10;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> A >> B;
    int cnt = getNrc(B) - 1;
    if (doar9(B)) cnt++;
    cout << 1LL * cnt * A << "\n";
  }
  return 0;
}
