#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b;
  cin >> a >> b;
  long long res = 0;
  long long cur = 0, cnt = 0;
  for (long long i = 1; i <= 10; i++, cnt++) {
    cur *= 10;
    cur += 9;
    if (cur > b) break;
  }
  cout << a * cnt << endl;
}
signed main() {
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
