#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 50;
const int INF = 0x3f3f3f3f;
void bf(int A, int B) {
  for (long long a = 1; a <= A; a++)
    for (long long b = 1; b <= B; b++) {
      if ((a * b + a + b) == stol(to_string(a) + to_string(b)))
        cout << a << " " << b << endl;
    }
}
int main() {
  int cs;
  while (cin >> cs) {
    while (cs--) {
      int a, b;
      cin >> a >> b;
      long long ret = to_string(b + 1).size() - 1;
      cout << a * ret << endl;
    }
  }
  return 0;
}
