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