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