#include <bits/stdc++.h>
using namespace std;
long long input() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
long long A, B;
int main() {
  int T = input();
  while (T--) {
    A = input(), B = input();
    long long cnt = 0;
    long long x = 9;
    while (x <= B) {
      cnt++;
      x = x * 10 + 9;
    }
    cout << A * cnt << endl;
  }
}
