#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll long long
#define ld long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const ll INF = 1ll*1000*1000*1000*1000*1000*1000 + 7;
using namespace std;
ll power(ll x, ll y)
{
if (y == 0)
return 1;
else if (y % 2 == 0)
return power(x, y / 2) * power(x, y / 2);
else
return x * power(x, y / 2) * power(x, y / 2);
}
int main()
{
int T;
cin>>T;
while(T--)
{
ll A;
string B;
cin>>A>>B;
ll X=B.length();
ll P=stoi(B);
if (P==(power(10, X)-1))
X=B.length();
else
X=B.length()-1;
ll C=A*X;
cout<<C<<'\n';
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+ICAgIAojZGVmaW5lIGZhc3RpbygpIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApCiNkZWZpbmUgcGIgIHB1c2hfYmFjawojZGVmaW5lIHNob3coeCkgY291dDw8KCN4KTw8IiA6ICI8PHg8PGVuZGw7CiNkZWZpbmUgbGwgIGxvbmcgbG9uZwojZGVmaW5lIGxkICBsb25nIGRvdWJsZQojZGVmaW5lIGZpbGwoYSx2YWwpIG1lbXNldChhLHZhbCxzaXplb2YoYSkpCiNkZWZpbmUgbXAgIG1ha2VfcGFpcgojZGVmaW5lIGZmICBmaXJzdAojZGVmaW5lIHNzICBzZWNvbmQKI2RlZmluZSBwaWkgcGFpcjxsbCxsbD4KI2RlZmluZSBzcSh4KSAoKHgpKih4KSkKI2RlZmluZSBhbGwodikgdi5iZWdpbigpLHYuZW5kKCkKI2RlZmluZSByYWxsKHYpIHYucmJlZ2luKCksdi5yZW5kKCkKY29uc3QgbGw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