#include <bits/stdc++.h>
using namespace std;
void solve() {
  int A, B;
  cin >> A >> B;
  int64_t b = 9;
  int64_t ans = 0;
  while (b <= B) {
    ans++;
    b = 10 * b + 9;
  }
  ans *= A;
  cout << ans << endl;
}
int main() {
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
