#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long cnt = 0;
    long long h = 9;
    while (h <= b) {
      ++cnt;
      h *= 10;
      h += 9;
    }
    cnt *= a;
    cout << cnt << '\n';
  }
}
