#include <bits/stdc++.h>
using namespace std;
int T;
int main() {
  cin >> T;
  while (T--) {
    int a, b;
    scanf("%d%d", &a, &b);
    long long cnt = 0;
    for (int i = 10; i - 1 <= b; i *= 10) {
      cnt++;
    }
    printf("%lld\n", a * cnt);
  }
  return 0;
}
