#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int A, B;
    cin >> A >> B;
    ll ans = 0;
    ll delta = 10;
    for (int i = 1; i <= 10; ++i) {
      if (delta - 1 > B) break;
      ++ans;
      delta *= 10;
    }
    cout << A * ans << '\n';
  }
  return 0;
}
