#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b;
  cin >> a >> b;
  long long sum = b + 1;
  long long c = 0;
  while (sum > 0) {
    sum /= 10;
    c += 1;
  }
  c -= 1;
  long long ans = a * c;
  cout << ans << endl;
}
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
