#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e5 + 10, MX2 = 1e9 + 2;
bool bo[MX];
pair<long long, long long> pa;
deque<long long> deq, deq2, deq3;
deque<pair<long long, long long>> dpa, dpa2, dpa3;
deque<pair<pair<long long, long long>, long long>> dpapa, dpapa2, dpapa3;
vector<long long> vec, vec2, vec3;
vector<long long> vec4, vec5, vec6;
vector<pair<long long, long long>> vpa, vpa2, vpa3, vpas[MX], vpas2[MX],
    vpas3[MX];
vector<pair<pair<long long, long long>, long long>> vpapa, vpapa2, vpapa3;
set<long long> se, se2, se3, se4, ses[MX], ses2[MX], ses3[MX];
set<pair<long long, long long>> sepa, sepa2, sepa3, sepas[MX], sepas2[MX],
    sepas3[MX];
set<pair<pair<long long, long long>, long long>> sepapa, sepapa2, sepapa3;
map<long long, long long> ma, ma2, ma3, ma4;
map<pair<long long, long long>, long long> mapa, mapa2, mapa3;
map<pair<long long, long long>, pair<long long, long long>> mapapa, mapapa2,
    mapapa3;
map<long long, pair<long long, long long>> malpa, malpa2, malpa3;
map<long long, pair<pair<long long, long long>, long long>> malpapa, malpapa2,
    malpapa3;
long long const MOD = 1e9 + 7;
long long maxi(long long a, long long b) { return max(a, b); }
long long mini(long long a, long long b) { return min(a, b); }
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin.tie(NULL);
  ;
  cout.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long as = b, c = 0, r = 0;
    while (as) {
      if (as % 10 == 9) {
        r++;
      }
      as /= 10;
      c++;
    }
    if (c == r) {
      cout << a * c << endl;
    } else {
      cout << a * (c - 1) << endl;
    }
  }
  return 0;
}
