#include <bits/stdc++.h>
using namespace std;
long long T;
long long n, m;
long long mi[210005];
void rd() {}
signed main() {
  cin >> T;
  while (T--) {
    cin >> n >> m;
    long long ans = 0;
    mi[0] = 1;
    for (long long i = 1; i <= 10; i++) mi[i] = mi[i - 1] * 10;
    for (long long i = 1; i <= 10; i++)
      if (mi[i] - 1 <= m) ans += n;
    cout << ans << "\n";
  }
  return 0;
}
