#include <bits/stdc++.h>
using namespace std;
int t;
long long a, b;
int main() {
  cin >> t;
  for (int cas = 1; cas <= t; ++cas) {
    cin >> a >> b;
    long long pn[11];
    pn[1] = 9;
    for (int i = 2; i <= 10; ++i) {
      pn[i] = pn[i - 1] * 10LL + 9LL;
    }
    long long ans = 0LL;
    for (int i = 1; i <= 9; ++i) {
      if (pn[i] <= b) {
        ans += a;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
