#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 5e6 + 7;
signed main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    long long a, b, ans = 0;
    cin >> a >> b;
    long long x = 9;
    while (x <= b) {
      ans++;
      x = x * 10 + 9ll;
    }
    cout << a * ans << "\n";
  }
  return 0;
}
