#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return x * f;
}
inline long long Mul(long long a, long long b) {
  return 1ll * a * b % 1000000007;
}
inline long long Inc(long long a, long long b) {
  return (a += b) >= 1000000007 ? a - 1000000007 : a;
}
inline long long Dec(long long a, long long b) {
  return (a -= b) < 0 ? a + 1000000007 : a;
}
inline long long qpow(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = Mul(r, a);
    a = Mul(a, a), b >>= 1;
  }
  return r;
}
long long n, m;
signed main() {
  long long T = read();
  while (T--) {
    long long a = read(), b = read(), ans = 0, x = 9;
    while (x <= b) ++ans, x = x * 10 + 9;
    printf("%I64d\n", ans * a);
  }
  return 0;
}
