#include <bits/stdc++.h>
int main() {
  int TC;
  scanf("%d", &TC);
  while (TC--) {
    long long int ans = 0;
    long long int a, b;
    scanf("%lld %lld", &a, &b);
    for (long long int i = 10; i <= b * 10; i *= 10) {
      long long int temp = i - 1;
      if (b >= temp) {
        ans += a;
      } else {
        break;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
