#include <bits/stdc++.h>
using namespace std;
long long t, a, b;
long long ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> t;
  for (int i = 1; i <= t; i++) {
    ans = 0;
    cin >> a >> b;
    int f = 0;
    while (f * 10 + 9 <= b) {
      f = f * 10 + 9;
      ans += a;
    }
    cout << ans << endl;
  }
  return 0;
}
