#include<stdio.h>
int main()
{
int a,b,a1,b1,b0,n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
int s=0;
scanf("%d%d",&a,&b);
b0=b;
while(a)
{
a1=a%10;
a/=10;
b=b0;
while(b)
{
b1=b%10;
b/=10;
s=s+a1*b1;
}
}
printf("%d
",s);
}return 0;
}