#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;
}