#include <bits/stdc++.h>
using namespace std;
int t;
int a, b;
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> a >> b;
    long long curr = 9;
    long long cnt = 0;
    while (curr <= b) {
      ++cnt;
      curr *= 10;
      curr += 9;
    }
    cout << a * cnt << endl;
  }
  return 0;
}
