#include <bits/stdc++.h>
using namespace std;
long long t, a, b, ans = 0;
int main() {
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld%lld", &a, &b);
    ans = 0;
    if (b >= 9) ans++;
    if (b >= 99) ans++;
    if (b >= 999) ans++;
    if (b >= 9999) ans++;
    if (b >= 99999) ans++;
    if (b >= 999999) ans++;
    if (b >= 9999999) ans++;
    if (b >= 99999999) ans++;
    if (b >= 999999999) ans++;
    printf("%lld\n", a * ans);
  }
  return 0;
}
