#include <bits/stdc++.h>
using namespace std;
long long a, b;
int T;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> T;
  while (T--) {
    cin >> a >> b;
    int c = 0, x = 10;
    while (x - 1 <= b) ++c, x *= 10;
    cout << a * c << endl;
  }
  return 0;
}
