#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll calc(ll x, ll d) { return x + (d + x) / (x + 1); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  for (int ti = 0; ti < t; ++ti) {
    ll n, m;
    cin >> n >> m;
    ll res = 0;
    ll pw = 10;
    while (m >= pw - 1) {
      ++res;
      pw *= 10;
    }
    res *= n;
    cout << res << '\n';
  }
}
