#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 77;
const int MOD = int(1e9) + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    long long a, b;
    cin >> a >> b;
    long long n = 9;
    long long ans = 0;
    while (n <= b) {
      ans += a;
      n *= 10;
      n += 9;
    }
    cout << ans << '\n';
  }
  return 0;
}
