#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int main() {
  std::ios::sync_with_stdio(false);
  long long n, m;
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    long long cnt = 0, num = 0;
    while (num * 10 + 9 <= m) {
      num *= 10, num += 9;
      cnt++;
    }
    cout << cnt * n << endl;
  }
  return 0;
}
