#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2500 + 5;
const int INF = 0x3f3f3f3f;
int b[25];
int main() {
  long long Case, c = 1;
  scanf("%lld", &Case);
  for (int i = 1; i <= 9; i++) {
    c *= 10;
    b[i] = c - 1;
  }
  while (Case--) {
    long long A, B, cnt = 0, i;
    scanf("%lld%lld", &A, &B);
    for (i = 1; i <= 9; i++)
      if (b[i] > B) break;
    if (b[i] > B || i > 9)
      cnt = i - 1;
    else
      cnt = i;
    printf("%lld\n", A * cnt);
  }
  return 0;
}
