#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long test, n, m, k, ans, q, a[N], b[N], c[N], d[N];
void solve() {
  cin >> n >> m;
  ans = 0;
  for (int i = 1; i <= 15; i++)
    if (m >= a[i]) ans += n;
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  a[1] = 9;
  for (int i = 2; i <= 15; i++) a[i] = 10 * a[i - 1] + 9;
  cin >> test;
  while (test--) solve();
}
