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