#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int a, b, ans;
  cin >> a >> b;
  long long int z = 9;
  long long int c = 0;
  while (b >= z) {
    c++;
    z = (z * 10) + 9;
  }
  ans = a * c;
  cout << ans;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q = 1;
  cin >> q;
  while (q--) {
    solve();
    cout << endl;
  }
  return 0;
}
