#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int t;
  cin >> t;
  while (t--) {
    ll a, b;
    cin >> a >> b;
    ll count = 0;
    ll arr[10] = {9,      99,      999,      9999,      99999,
                  999999, 9999999, 99999999, 999999999, 9999999999};
    for (int i = 0; i < 10; i++) {
      if (b >= arr[i])
        count++;
      else {
        break;
      }
    }
    cout << a * count << endl;
  }
}
