#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
ll arr[100010],d[100005],n;

int calc(ll a,ll k){
	set<ll> t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t.insert(-i);
			t.insert(-a/i);
		}
	}
	for(auto&x:t){
		d[-x]+=d[-x-1];
		d[-x]%=INF;
	}
	return 0;
}
int main(){
	d[0]=1;
	cin>>n;
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	for(int i=0;i<n;i++){
		cin>>arr[i];
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&z:d){
		ans+=z;
		ans%=INF;
	}
	ans=ans-1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
map<ll,ll>d;
ll arr[100010],n;
void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t[i]=d[i-1];
			cout<<t[i];
			if(i*i!=a)t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t){
		d[x.first]+=x.second;
		d[x.first]%=INF;
	}
}
int main(){
	d[0]=1;
	cin>>n;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for(int i=0;i<n;i++)cin>>arr[i];
	for(int i=0;i<n;i++){
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&x:d){
		ans%=INF;
		ans+=x.second;
	}
	ans-=1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>d;
ll a[100010],n;
void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t[i]=d[i-1];
			if(i*i!=a)t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t)d[x.first]+=x.second;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	d[0]=1;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		calc(a[i],i+1);
	}
	ll ans=0;
	for(auto&x:d)ans+=x.second;
	ans-=1;
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
ll arr[100010],d[100005];

int calc(ll a,ll k){
	set<ll> t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t.insert(-i);
			t.insert(-a/i);
		}
	}
	for(auto&x:t){
		d[-x]+=d[-x-1];
		d[-x]%=INF;
	}
	return 0;
}
int main(){
	d[0]=1;
	int n;
	cin>>n;
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	for(int i=0;i<n;i++){
		cin>>arr[i];
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&z:d){
		ans+=z;
		ans%=INF;
	}
	ans=ans-1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
ll arr[100010],d[1000005];

int solve(ll a,ll k){
	vector<ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t.push_back(i);
			if(i*i!=a)t.push_back(a/i);
		}
	}
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	for(auto&x:t){
		d[x]+=d[x-1];
		d[x]%=INF;
	}
	return 0;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	d[0]=1;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		solve(arr[i],i+1);
	}
	ll ans=0;
	for(auto&z:d){
		ans+=z;
		ans%=INF;
	}
	ans=ans-1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
map<ll,ll>d;
ll arr[100010],n;
void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t[i]=d[i-1];
			if(i*i!=a)t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t){
		d[x.first]+=x.second;
		d[x.first]%=INF;
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	d[0]=1;
	cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	for(int i=0;i<n;i++){
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&x:d){
		ans%=INF;
		ans+=x.second;
	}
	ans-=1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
ll arr[100010],d[100005],n;

void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t[i]=d[i-1];
			if(i*i!=a)t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t){
		d[x.first]+=x.second;
		d[x.first]%=INF;
	}
	return;
}
int main(){
	d[0]=1;
	cin>>n;
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	for(int i=0;i<n;i++){

		cin>>arr[i];
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&z:d){
		ans+=z;
		ans%=INF;
	}
	ans=ans-1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
ll arr[100010],d[100005],n;

void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t[i]=d[i-1];
			if(i*i!=a)t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t){
		d[x.first]+=x.second;
		d[x.first]%=INF;
	}
	return;
}
int main(){
	d[0]=1;
	cin>>n;
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	for(int i=0;i<n;i++){
		cin>>arr[i];
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&z:d){
		ans+=z;
		ans%=INF;
	}
	ans-=1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
ll arr[100010],d[100005];

int calc(ll a,ll k){
	vector<ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t.push_back(i);
			if(i*i!=a)t.push_back(a/i);
		}
	}
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	for(auto&x:t){
		d[x]+=d[x-1];
		d[x]%=INF;
	}
	return 0;
}
int main(){
	d[0]=1;
	int n;
	cin>>n;
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	for(int i=0;i<n;i++){
		cin>>arr[i];
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&z:d){
		ans+=z;
		ans%=INF;
	}
	ans=ans-1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
map<ll,ll>d;
ll arr[100010],n;
void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t[i]=d[i-1];
			if(i*i!=a)t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t){
		d[x.first]+=x.second;
		d[x.first]%=INF;
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	d[0]=1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&x:d){
		ans+=x.second;
		ans%=INF;
	}
	ans-=1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
map<ll,ll>d;
ll arr[100010],n;
void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			if(d.count(i-1))t[i]=d[i-1];
			if(i*i!=a && d.count(a/i-1))t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t){
		d[x.first]+=x.second;
		d[x.first]%=INF;
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	d[0]=1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&x:d){
		ans+=x.second;
		ans%=INF;
	}
	ans-=1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>d;
ll a[100010],n;
void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t[i]=d[i-1];
			if(i*i!=a)t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t)d[x.first]+=x.second;
}
int main(){
	d[0]=1;
	cin>>n;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		calc(a[i],i+1);
	}
	ll ans=0;
	for(auto&x:d)ans+=x.second;
	ans-=1;
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+10;
map<ll,ll>d;
ll a[100010],n;
void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t[i]=d[i-1];
			if(i*i!=a)t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t){
		d[x.first]+=x.second;
		d[x.first]%=INF;
	}
}
int main(){
	d[0]=1;
	cin>>n;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		calc(a[i],i+1);
	}
	ll ans=0;
	for(auto&x:d){
		ans%=INF;
		ans+=x.second;
	}
	ans-=1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
ll arr[100010],d[100005],n;
void calc(ll a,ll k){
	map<ll,ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t[i]=d[i-1];
			if(i*i!=a)t[(a/i)]=d[(a/i)-1];
		}
	}
	for(auto&x:t){
		d[x.first]+=x.second;
		d[x.first]%=INF;
	}
}
int main(){
	d[0]=1;
	cin>>n;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for(int i=0;i<n;i++)cin>>arr[i];
	for(int i=0;i<n;i++){
		calc(arr[i],i+1);
	}
	ll ans=0;
	for(auto&x:d){
		ans+=x;
		ans%=INF;
	}
	ans-=1;
	cout<<(ans+INF)%INF;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e9)+7;
ll arr[100010],d[100005];

int solve(ll a,ll k){
	vector<ll>t;
	for(int i=1;(i*i<=a)&&(i<=k);i++){
		if(a%i==0){
			t.push_back(i);
			if(i*i!=a)t.push_back(a/i);
		}
	}
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	for(auto&x:t){
		d[x]+=d[x-1];
		d[x]%=INF;
	}
	return 0;
}

int main(){
	d[0]=1;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		solve(arr[i],i+1);
	}
	ll ans=0;
	for(auto&z:d){
		ans+=z;
		ans%=INF;
	}
	ans=ans-1;
	cout<<(ans+INF)%INF;
}


#include <stdio.h>

int main() {
	int t, a, b, ans;
	scanf("%d", &t);
	while (t--) {
		scanf("%d%d", &a, &b);
		b++;
		ans = 0;
		while (b > 9) {
			ans++;
			b /= 10;
		}
		printf("%I64d\n", (long long)a * ans);
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define LL long long
int b[20];
int main(){
	int t,A,B,c=1,i,cnt;
	for(i=1;i<=9;i++)
		c*=10,b[i]=c-1;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d",&A,&B);
		for(i=1;i<=9;i++)
			if(b[i]>B)break;
		if(b[i]>B)cnt=i-1;
		else if(i>9)cnt=i-1;//lose the line.
		else cnt=i;
		printf("%lld\n",(LL)cnt*A);
	}
	return 0;}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#define ll long long

/*
ll conc ( ll a, ll b)
{
	ll working_number=b;
	int count=0;

	while(working_number != 0){
		working_number /= 10;
		++count;
	}

	if(count == 1)
		return a*10+b;
	else if(count == 2)
		return a*100+b;
	else if(count == 3)
		return a*1000+b;
	else if(count == 4)
		return a*10000+b;
	else if(count == 5)
		return a*100000+b;
	else if(count == 6)
		return a*1000000+b;
	else if(count == 7)
		return a*10000000+b;
	else if(count == 8)
		return a*100000000+b;
	else
		return a*1000000000+b;
}

ll bestpair ( ll number_one, ll number_two)
{
	ll i=0, j=0, left=0, right=0, count=0;
	for(i=1 ; i<number_one+1 ; i++)
		for(j=9 ; j<number_two+1 ; j=(j*10)+9){
			left = (i*j)+i+j;
			right = conc(i,j);
			if(left == right)
				++count;
		}
	return count;
}
*/
ll conc ( ll a, ll b)
{
	int i=0, arr[10]={0}, count=0;
	if(b<9)
		return 0;
	while(b != 0){
		arr[i] = b%10;
		i++;
		b/=10;
		++count;
	}
	count -= 1;
	for(i=0 ; i<count ; i++)
		if(arr[i] != 9)
			break;

	if(i == count)
		return a*(count+1);
	else
		return a*count;
}

int main ()
{
	ll arr[101][2]={0};
	int limit=0, i=0, j=0, newline=0;

	scanf("%d",&limit);
	for(i=0 ; i<limit ; i++)
		scanf("%lld %lld", &arr[i][0], &arr[i][1]);

	for(i=0 ; i<limit ; i++){
		if(newline++)
			printf("\n");
		printf("%lld",conc(arr[i][0] , arr[i][1]));
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#define ll long long

/*
ll conc ( ll a, ll b)
{
	ll working_number=b;
	int count=0;

	while(working_number != 0){
		working_number /= 10;
		++count;
	}

	if(count == 1)
		return a*10+b;
	else if(count == 2)
		return a*100+b;
	else if(count == 3)
		return a*1000+b;
	else if(count == 4)
		return a*10000+b;
	else if(count == 5)
		return a*100000+b;
	else if(count == 6)
		return a*1000000+b;
	else if(count == 7)
		return a*10000000+b;
	else if(count == 8)
		return a*100000000+b;
	else
		return a*1000000000+b;
}

ll bestpair ( ll number_one, ll number_two)
{
	ll i=0, j=0, left=0, right=0, count=0;
	for(i=1 ; i<number_one+1 ; i++)
		for(j=9 ; j<number_two+1 ; j=(j*10)+9){
			left = (i*j)+i+j;
			right = conc(i,j);
			if(left == right)
				++count;
		}
	return count;
}
*/
ll conc ( ll a, ll b)
{
	int i=0, arr[10]={0}, count=0, ans=0;
	if(b<9)
		return 0;
	while(b != 0){
		arr[i] = b%10;
		i++;
		b/=10;
		++count;
	}
	ans = count-1;
	for(i=0 ; i<count ; i++)
		if(arr[i] != 9)
			break;

	if(i == count)
		return a*(ans+1);
	else
		return a*ans;
}

int main ()
{
	ll arr[101][2]={0};
	int limit=0, i=0, j=0, newline=0;

	scanf("%d",&limit);
	for(i=0 ; i<limit ; i++)
		scanf("%lld %lld", &arr[i][0], &arr[i][1]);

	for(i=0 ; i<limit ; i++){
		if(newline++)
			printf("\n");
		printf("%lld",conc(arr[i][0] , arr[i][1]));
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#define ll long long

ll conc ( ll a, ll b)
{
	ll working_number=b;
	int count=0;

	while(working_number != 0){
		working_number /= 10;
		++count;
	}

	if(count == 1)
		return a*10+b;
	else if(count == 2)
		return a*100+b;
	else if(count == 3)
		return a*1000+b;
	else if(count == 4)
		return a*10000+b;
	else if(count == 5)
		return a*100000+b;
	else if(count == 6)
		return a*1000000+b;
	else if(count == 7)
		return a*10000000+b;
	else if(count == 8)
		return a*100000000+b;
	else
		return a*1000000000+b;
}

ll bestpair ( ll number_one, ll number_two)
{
	ll i=0, j=0, left=0, right=0, count=0;
	for(i=1 ; i<number_one+1 ; i++)
		for(j=9 ; j<number_two+1 ; j=(j*10)+9){
			left = (i*j)+i+j;
			right = conc(i,j);
			if(left == right)
				++count;
		}
	return count;
}

int main ()
{
	ll arr[101][2]={0};
	int limit=0, i=0, j=0, newline=0;

	scanf("%d",&limit);
	for(i=0 ; i<limit ; i++)
		scanf("%lld %lld", &arr[i][0], &arr[i][1]);

	for(i=0 ; i<limit ; i++){
		if(newline++)
			printf("\n");
		printf("%lld",bestpair(arr[i][0] , arr[i][1]));
	}

	return 0;
}


#include<stdio.h>
#include<math.h>

int main(){
int n;

 long long a ,b;
scanf("%d",&n);
while(n--){

scanf("%lld %lld",&a,&b);
int count=log10(b+1);

{printf("%lld\n",a*(count));}

}
return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	int m,a,n,d,i;
	char b[100];
	scanf("%d",&m);
	while(m--)
	{
		d=1;
		scanf("%d%s",&a,&b);
		n=strlen(b);
		for(i=0;i<n;i++)
		{
			if(b[i]!='9')d=0;
		}
		printf("%lld\n",a*(n+d-1));
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	int m,a,n,d,i;
	char b[100];
	scanf("%d",&m);
	while(m--)
	{
		d=1;
		scanf("%d%s",&a,&b);
		n=strlen(b);
		for(i=0;i<n;i++)
		{
			if(b[i]!='9')d=0;
		}
		printf("%.0f\n",a*1.0*(n+d-1));
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	int m,a,n,d,i;
	char b[10];
	scanf("%d",&m);
	while(m--)
	{
		d=1;
		scanf("%d%s",&a,&b);
		n=strlen(b);
		for(i=0;i<n;i++)
		{
			if(b[i]!='9')d=0;
		}
		printf("%d\n",a*(n+d-1));
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int qtDigs(int n){
    int ans = 0;
    while(n){
        n /= 10;
        ans++;
    }
    return ans;
}

int main() {

    int qtt, a, b;
    scanf("%d", &qtt);

    while(qtt--){
        scanf("%d %d", &a, &b);
        printf("%lld\n", ((long long)a)*(qtDigs(b+1)-1));
    }

	return 0;
}


#include <stdio.h>
int main()
{
	int t;
	scanf("%d",&t);
	long long int a,b;
	while(t--)
	{
		scanf("%lld %lld",&a,&b);
		long long int j=9;
		long long int cncat=0;
		while(j<=b)
		{
			j=j*10+9;
			cncat++;
		}
		printf("%lld\n",cncat*a);
	}
	return 0;
}


#include <stdio.h>
int main()
{
    int q, A, B;
    scanf("%d", &q);
    while(q--)
    {
        scanf("%d%d", &A, &B);
        int n = 10, ans = 0;
        for(int i = 1; i <=10; i++)
        {
            if(B < n)
                break;
            n *= 10;
            ans++;
        }
        printf("%d\n", ans*A);
    }
}


#include <stdio.h>
int main()
{
    int q, A, B;
    scanf("%d", &q);
    while(q--)
    {
        scanf("%d%d", &A, &B);
        int n = 10, ans = 0;
        for(int i = 1; i <=10; i++)
        {
            if(B < n-1)
                break;
            n *= 10;
            ans++;
        }
        printf("%d\n", ans*A);
    }
}


#include <stdio.h>
int main()
{
    int q, A, B;
    scanf("%d", &q);
    while(q--)
    {
        scanf("%d%d", &A, &B);
        int n = 10;
        long long int ans = 0;
        for(int i = 1; i <=10; i++)
        {
            if(B < n-1)
                break;
            n *= 10;
            ans++;
        }
        printf("%I64d\n", ans*A);
    }
}


#include<stdio.h>
#include<math.h>
long long int n,a,b,i,ii,t;
int main()
{
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("lld%lld",&a,&b);
		for(ii=1,t=0;ii*9<=b;ii=ii*10+1,t++);
		printf("%lld\n",t*a);

	}

	return 0;
 }


#include<stdio.h>
#include<math.h>
long long int n,a,b,x,y,t;
int main()
{
	scanf("%d",&n);
	for(x=0;x<n;x++)
	{
		scanf("lld%lld",&a,&b);
		for(y=1,t=0;y*9<=b;t++)
			y=y*10+1;
		printf("%lld\n",t*a);

	}

	return 0;
 }


#include<stdio.h>
#include<math.h>
long long int n,a,b,x,y,t;
int main()
{
	scanf("%d",&n);
	for(x=0;x<n;x++)
	{
		scanf("lld%lld",&a,&b);
		for(y=1,t=0;y*9<=b;y=y*10+1,t++);
		printf("%lld\n",t*a);

	}

	return 0;
 }


#include<stdio.h>
#include<math.h>
long long int n,a,b,i,ii,t;
int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld%lld",&a,&b);
		for(ii=1,t=0;ii*9<=b;ii=ii*10+1,t++);
		printf("%lld\n",t*a);

	}

	return 0;
 }


#include<stdio.h>
#include<math.h>
long long int n,a,b,x,y,t;
int main()
{
	scanf("%lld",&n);
	for(x=0;x<n;x++)
	{
		scanf("lld%lld",&a,&b);
		for(y=1,t=0;y*9<=b;y=y*10+1,t++);
		printf("%lld\n",t*a);

	}

	return 0;
 }


#include <stdio.h>
#include <limits.h>

int main(void){
    int t;
    scanf("%d", &t);

    for(int i = 0; i < t; i++){
        unsigned long long a, b, count = 0;
        scanf("%llu %llu", &a, &b);

        for(unsigned long long j = 9; j <= b; j = j * 10 + 9)
            count += a;

        printf("%llu\n", count);
    }
    return 0;
}


#include <stdio.h>
#include <limits.h>

int main(void){
    int t;
    scanf("%d", &t);

    for(int i = 0; i < t; i++){
        int a, b, count = 0;
        scanf("%d %d", &a, &b);

        for(int j = 9; j <= b; j = j * 10 + 9)
            count += a;

        printf("%d\n", count);
    }
    return 0;
}


#include <stdio.h>
#include <limits.h>

int main(void){
    int t;
    scanf("%d", &t);

    for(int i = 0; i < t; i++){
        unsigned long long a, b, count = 0;
        scanf("%llu %llu", &a, &b);

        for(unsigned long long j = 9; j < b; j = j * 10 + 9)
            count += a;

        printf("%llu\n", count);
    }
    return 0;
}


#include<stdio.h>

long long int r_u_mene(long long int a, long long int b);
long long int Pow(int n);

int main() {
	int t;
	long long int  a, b;

	scanf("%d", &t);

	while (t--) {
		scanf("%lld%lld", &a, &b);

		printf("%lld\n", r_u_mene(a, b));
	}
}

long long int Pow( int n) {

	if (n == 0)
		return 1;

	else if (n % 2==0)
		return Pow(n / 2) * Pow(n / 2);

	else
		return Pow(n / 2) * Pow(n / 2) * 10;
}

long long int r_u_mene(long long int a, long long int b) {

	long long int max = a > b ? a : b;
	long long int min = a > b ? b : a;
	long long int nine_nine = 9;
	int max_digit = 0;

	while (max >= nine_nine != 0) {
		max_digit++;
		nine_nine = nine_nine * 10 + 9;
	}

	return (max_digit)* min;

}


#include<stdio.h>

long long int r_u_mene(long long int a, long long int b);
long long int Pow(int n);

int main() {
	int t;
	long long int  a, b;

	scanf("%d", &t);

	while (t--) {
		scanf("%lld%lld", &a, &b);

		printf("%lld\n", r_u_mene(a, b));
	}
}

long long int Pow( int n) {

	if (n == 0)
		return 1;

	else if (n % 2==0)
		return Pow(n / 2) * Pow(n / 2);

	else
		return Pow(n / 2) * Pow(n / 2) * 10;
}

long long int r_u_mene(long long int a, long long int b) {

	long long int nine_nine = 9;
	int b_digit = 0;

	while (b >= nine_nine) {
		b_digit++;
		nine_nine = nine_nine * 10 + 9;
	}

	return b_digit* a;

}


#include<stdio.h>

int r_u_mene(long long int a, long long int b);
long long int Pow(long long int n);

int main() {
	int t;
	long long int  a, b;

	scanf("%d", &t);

	while (t--) {

		scanf("%lld%lld", &a, &b);

		printf("%d\n", r_u_mene(a, b));
	}
}

long long int Pow(long long int n) {

	if (n == 0)
		return 1;

	else if (n % 2==0)
		return Pow(n / 2) * Pow(n / 2);

	else
		return Pow(n / 2) * Pow(n / 2) * 10;
}

int r_u_mene(long long int a, long long int b) {

	int c = a > b ? a : b;
	int d = a > b ? b : a;
	int c_digit = 0;
	int i = 0;

	while (c / Pow(i) != 0)
		i++;

	c_digit = i;

	return (c_digit - 1) * a;
}


#include<stdio.h>

long long int r_u_mene(long long int a, long long int b);
long long int Pow(long long int n);

int main() {
	int t;
	long long int  a, b;

	scanf("%d", &t);

	while (t--) {

		scanf("%lld%lld", &a, &b);

		printf("%lld\n", r_u_mene(a, b));
	}
}

long long int Pow(long long int n) {

	if (n == 0)
		return 1;

	else if (n % 2==0)
		return Pow(n / 2) * Pow(n / 2);

	else
		return Pow(n / 2) * Pow(n / 2) * 10;
}

long long int r_u_mene(long long int a, long long int b) {

	int c = a > b ? a : b;
	int d = a > b ? b : a;
	int c_digit = 0;
	int i = 0;

	while (c / Pow(i) != 0)
		i++;

	c_digit = i;

	return (c_digit - 1) * a;
}


#include<stdio.h>
#include<stdbool.h>

long long int conc(long long int a, long long int b);
long long int Pow(long long int n);
bool r_u_mene(long long int a, long long int b);
int ans;

int main() {
	int t;
	long long int A, B, a, b;

	scanf("%d", &t);

	while (t--) {
		ans = 0;
		scanf("%lld%lld", &a, &b);

		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				if (i % 10 == 9 || j % 10 == 9) {
					if (r_u_mene(i, j)) {
						ans++;
					}
					else continue;
				}
			}
		}
		printf("%d\n", ans);
	}
}

long long int conc(long long int a, long long int b) {
	long long int count = 1;
	long long int temp = b;

	while (temp > 9) {
		temp /= 10;
		count++;
	}

	return (long long int)Pow(count) * a + b;
}

long long int Pow(long long int n) {

	if (n == 1)
		return 10;

	else if (n % 2==0)
		return Pow(n / 2) * Pow(n / 2);

	else
		return Pow(n / 2) * Pow(n / 2) * 10;
}

bool r_u_mene(long long int a, long long int b) {
	if (((a * b) + a + b) == conc(a, b))
		return true;
	else return false;
}


#include<stdio.h>

long long int r_u_mene(long long int a, long long int b);
long long int Pow(long long int n);

int main() {
	int t;
	long long int  a, b;

	scanf("%d", &t);

	while (t--) {

		scanf("%lld%lld", &a, &b);

		printf("%d\n", r_u_mene(a, b));
	}
}

long long int Pow(long long int n) {

	if (n == 0)
		return 1;

	else if (n % 2==0)
		return Pow(n / 2) * Pow(n / 2);

	else
		return Pow(n / 2) * Pow(n / 2) * 10;
}

long long int r_u_mene(long long int a, long long int b) {

	int c = a > b ? a : b;
	int d = a > b ? b : a;
	int c_digit = 0;
	int i = 0;

	while (c / Pow(i) != 0)
		i++;

	c_digit = i;

	return (c_digit - 1) * a;
}


#include<stdio.h>

long long int r_u_mene(long long int a, long long int b);
long long int Pow(int n);

int main() {
	int t;
	long long int  a, b;

	scanf("%d", &t);

	while (t--) {

		scanf("%lld%lld", &a, &b);

		printf("%lld\n", r_u_mene(a, b));
	}
}

long long int Pow( int n) {

	if (n == 0)
		return 1;

	else if (n % 2==0)
		return Pow(n / 2) * Pow(n / 2);

	else
		return Pow(n / 2) * Pow(n / 2) * 10;
}

long long int r_u_mene(long long int a, long long int b) {

	long long int max = a > b ? a : b;
	long long int min = a > b ? b : a;
	int max_digit = 0;

	while (max / Pow(max_digit) != 0)
		max_digit++;

	if ((max + 1) / Pow(max_digit) != 0)
		return (max_digit)* min;

	else
		return (max_digit - 1) * min;
}


#include<stdio.h>
#include<stdbool.h>

long long int conc(long long int a, long long int b);
long long int Pow(long long int n);
bool r_u_mene(long long int a, long long int b);
int ans;

int main() {
	int t;
	long long int  a, b, temp;

	scanf("%d", &t);

	while (t--) {
		ans = 0;	temp = 9;
		scanf("%lld%lld", &a, &b);

		while (temp <= a) {
			for (int i = 0; i < b; i++) {
				if (r_u_mene(i, temp))
					ans++;
			}
			temp += 10;
		}
		temp = 9;
		while (temp <= b) {
			for (int i = 0; i < a; i++) {
				if (r_u_mene(i, temp))
					ans++;
			}
			temp += 10;
		}
		printf("%d\n", ans);
	}
}

long long int conc(long long int a, long long int b) {

	long long int count = 1;
	long long int temp = b;

	while (temp > 9) {
		temp /= 10;
		count++;
	}

	return (long long int)Pow(count) * a + b;
}

long long int Pow(long long int n) {

	if (n == 1)
		return 10;

	else if (n % 2==0)
		return Pow(n / 2) * Pow(n / 2);

	else
		return Pow(n / 2) * Pow(n / 2) * 10;
}

bool r_u_mene(long long int a, long long int b) {
	if (((a * b) + a + b) == conc(a, b))
		return true;
	else return false;
}


#include<stdio.h>

long long int r_u_mene(long long int a, long long int b);
long long int Pow(long long int n);

int main() {
	int t;
	long long int  a, b;

	scanf("%d", &t);

	while (t--) {

		scanf("%lld%lld", &a, &b);

		printf("%lld\n", r_u_mene(a, b));
	}
}

long long int Pow( int n) {

	if (n == 0)
		return 1;

	else if (n % 2==0)
		return Pow(n / 2) * Pow(n / 2);

	else
		return Pow(n / 2) * Pow(n / 2) * 10;
}

long long int r_u_mene(long long int a, long long int b) {

	long long int max = a > b ? a : b;
	long long int min = a > b ? b : a;
	int max_digit = 0;

	while (max / Pow(max_digit) != 0)
		max_digit++;

	if ((max + 1) / Pow(max_digit) != 0)
		return (max_digit)* min;

	else
		return (max_digit - 1) * min;
}


#include<stdio.h>
#include<math.h>
// define test case with two integers
typedef struct
{
    int A;
    int B;
}test;

// function to concatenate two no.s
int conc(int a, int b)
{
    int i, flag=0, value;
    while(b>=1)         //finding no. of digits in b
    {
        flag++;
        b = b/10;
    }
    value = a*pow(10,flag) + b;
    return value;
}

// function to compute the no. of pairs
int compute(int A, int B)
{
    int a, b, flag = 0;
    for(a=1; a<A; a++)
    {
        for(b=1; b<B; b++)
        {
            if(a*b+a+b == conc(a,b))
                flag++;        //updating flag if found a pair
        }
    }
    return flag;
}

void main()
{
    //input no. of test cases
    int n, i, pairs;
    scanf("%d", &n);

    //array containing n pairs of A,B
    test case[n];
    for(i=0;i<n;i++)
        scanf("%d %d",&case[i].A,&case[i].B);

    for(i=0;i<n;i++)
    {
        pairs = compute(case[i].A, case[i].B);  //computing pairs no. for each case
        printf("%d\n",pairs);
    }
}


#include<stdio.h>
#include<math.h>
// define test case with two integers
typedef struct
{
    int A;
    int B;
}test;

// function to concatenate two no.s
int conc(int a, int b)
{
    int i, flag=0, value;
    while(b>=1)         //finding no. of digits in b
    {
        flag++;
        b = b/10;
    }
    value = a*pow(10,flag) + b;
    return value;
}

// function to compute the no. of pairs
int compute(int A, int B)
{
    int a, b, flag = 0;
    float k;
    for(a=1; a<=A; a++)
    {
        for(b=9; b<=B; b++) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
        {
            k = log10(float(b+1));
            if(k-(int)k == 0)
            {
                if(a*b+a+b == conc(a,b))
                    flag++;        //updating flag if found a pair
            }
        }
    }
    return flag;
}

void main()
{
    //input no. of test cases
    int n, i, pairs;
    scanf("%d", &n);

    //array containing n pairs of A,B
    test c[n];
    for(i=0;i<n;i++)
        scanf("%d %d",&c[i].A,&c[i].B);

    for(i=0;i<n;i++)
    {
        pairs = compute(c[i].A, c[i].B);  //computing pairs no. for each case
        printf("%d\n",pairs);
    }
}


    #include<stdio.h>
    #include<math.h>

    // function to compute the no. of pairs
    int compute(int A, int B)

        for(b=9; b<=B; b=b*10+9) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
        {
            flag = flag + A;   //updating flag if found a pair
        }
        return flag;
    }

    void main()
    {
        //input no. of test cases
        int n, i, pairs;
        scanf("%d", &n);

        for(i=0;i<n;i++)
        {
            int A, B, b, flag = 0;;
            scanf("%d %d",&A,&B);
            for(b=9; b<=B; b=b*10+9) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
            {
                flag = flag + A;   //updating flag if found a pair
            }
            printf("%d\n",flag);
        }
    }


#include<stdio.h>
#include<math.h>

// function to compute the no. of pairs
int compute(int A, int B)
{
    int a, b, flag = 0;
    float k;

    for(b=9; b<=B; b++) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
    {
        k = log10((float)(b+1));
        if(k-(int)k == 0)
        {
            flag++;        //updating flag if found a pair
        }
    }
    return flag;
}

void main()
{
    //input no. of test cases
    int n, i, pairs;
    scanf("%d", &n);

    //array containing n pairs of A,B

    for(i=0;i<n;i++)
    {
        int A, B;
        scanf("%d %d",&A,&B);
        pairs = compute(A, B);  //computing pairs no. for each case
        printf("%d\n",pairs);
    }
}


#include<stdio.h>
#include<math.h>

int main()
{
    //input no. of test cases
    int n, i;
    scanf("%d", &n);

    for(i=0;i<n;i++)
    {
        int A, B, b;
        long long int flag = 0;
        scanf("%d %d",&A,&B);
        for(b=9; b<=B; b=b*10+9) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
        {
            flag = flag + A;   //updating flag if found a pair
        }
        printf("\n%lld\n",flag);
    }
}


#include<stdio.h>
#include<math.h>
// define test case with two integers
typedef struct
{
    int A;
    int B;
}test;

// function to concatenate two no.s
int conc(int a, int b)
{
    int i, flag=0, value;
    while(b>=1)         //finding no. of digits in b
    {
        flag++;
        b = b/10;
    }
    value = a*pow(10,flag) + b;
    return value;
}

// function to compute the no. of pairs
int compute(int A, int B)
{
    int a, b, flag = 0;
    for(a=1; a<A; a++)
    {
        for(b=1; b<B; b++)
        {
            if(a*b+a+b == conc(a,b))
                flag++;        //updating flag if found a pair
        }
    }
    return flag;
}

void main()
{
    //input no. of test cases
    int n, i, pairs;
    scanf("%d", &n);

    //array containing n pairs of A,B
    test c[n];
    for(i=0;i<n;i++)
        scanf("%d %d",&c[i].A,&c[i].B);

    for(i=0;i<n;i++)
    {
        pairs = compute(c[i].A, c[i].B);  //computing pairs no. for each case
        printf("%d\n",pairs);
    }
}


    #include<stdio.h>
    #include<math.h>

    // function to compute the no. of pairs
    int compute(int A, int B)
    {
        int a, b, flag = 0;
        float k;

        for(b=9; b<=B; b=b*10+9) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
        {
            flag = flag + A;   //updating flag if found a pair
        }
        return flag;
    }

    void main()
    {
        //input no. of test cases
        int n, i, pairs;
        scanf("%d", &n);

        for(i=0;i<n;i++)
        {
            int A, B;
            scanf("%d %d",&A,&B);
            pairs = compute(A, B);  //computing pairs no. for each case
            printf("%d\n",pairs);
        }
    }


#include<stdio.h>
#include<math.h>

int main()
{
    //input no. of test cases
    int n, i;
    scanf("%d", &n);

    for(i=0;i<n;i++)
    {
        int A, B, b;
        float flag = 0;
        scanf("%d %d",&A,&B);
        for(b=9; b<=B; b=b*10+9) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
        {
            flag = flag + A;   //updating flag if found a pair
        }
        printf("\n%d\n",flag);
    }
}


#include<stdio.h>
#include<math.h>

int main()
{
    //input no. of test cases
    int n, i;
    scanf("%d", &n);

    for(i=0;i<n;i++)
    {
        int A, B, b, flag = 0;;
        scanf("%d %d",&A,&B);
        for(b=9; b<=B; b=b*10+9) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
        {
            flag = flag + A;   //updating flag if found a pair
        }
        printf("\n%d\n",flag);
    }
}


#include<stdio.h>
#include<math.h>

// function to compute the no. of pairs
int compute(int A, int B)
{
    int a, b, flag = 0;
    float k;

    for(b=9; b<=B; b=b*10+9) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
    {
        flag++;        //updating flag if found a pair
    }
    return flag;
}

void main()
{
    //input no. of test cases
    int n, i, pairs;
    scanf("%d", &n);

    for(i=0;i<n;i++)
    {
        int A, B;
        scanf("%d %d",&A,&B);
        pairs = compute(A, B);  //computing pairs no. for each case
        printf("%d\n",pairs);
    }
}


#include<stdio.h>
#include<math.h>
// define test case with two integers
typedef struct
{
    int A;
    int B;
}test;

// function to concatenate two no.s
int conc(int a, int b)
{
    int i, flag=0, value;
    while(b>=1)         //finding no. of digits in b
    {
        flag++;
        b = b/10;
    }
    value = a*pow(10,flag) + b;
    return value;
}

// function to compute the no. of pairs
int compute(int A, int B)
{
    int a, b, flag = 0;
    float k;
    for(a=1; a<=A; a++)
    {
        for(b=9; b<=B; b++) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
        {
            k = log10((float)(b+1));
            if(k-(int)k == 0)
            {
                if(a*b+a+b == conc(a,b))
                    flag++;        //updating flag if found a pair
            }
        }
    }
    return flag;
}

void main()
{
    //input no. of test cases
    int n, i, pairs;
    scanf("%d", &n);

    //array containing n pairs of A,B
    test c[n];
    for(i=0;i<n;i++)
        scanf("%d %d",&c[i].A,&c[i].B);

    for(i=0;i<n;i++)
    {
        pairs = compute(c[i].A, c[i].B);  //computing pairs no. for each case
        printf("%d\n",pairs);
    }
}


    #include<stdio.h>
    #include<math.h>

    void main()
    {
        //input no. of test cases
        int n, i;
        scanf("%d", &n);

        for(i=0;i<n;i++)
        {
            int A, B, b, flag = 0;;
            scanf("%d %d",&A,&B);
            for(b=9; b<=B; b=b*10+9) //we have to get a*(b+1)+b = a*(10 to the power something)+b; so b is of form pow(10,k)-1
            {
                flag = flag + A;   //updating flag if found a pair
            }
            printf("\n%d\n",flag);
        }
    }


#include <stdio.h>
int main()
{
	int t;
	scanf("%d",&t);
	long long int a,b;
	while(t--)
	{
		scanf("%lld %lld",&a,&b);
		long long int j=9;
		long long int cnt=0;
		while(j<=b)
		{
			j=j*10+9;
			cnt++;
		}
		printf("%lld\n",cnt*a);
	}
	return 0;
}


#include <stdio.h>
int main()
{
	int t;
	scanf("%d",&t);
	long long int a,b;
	while(t--)
	{
		scanf("%lld %lld",&a,&b);
		long long int j=9;
		long long int cnt=0;
		while(j<=b)
		{
			j=j*10+9;
			cnt++;
		}
		printf("%lld\n",cnt*a);
	}
	return 0;


#include<stdio.h>
int main()
{
	long long t,i,n;
	long long a, b;
	scanf("%lld",&t);
	n=t;
	i=0;
    long long T[1000];
	while (t --)
	{
		scanf("%lld %lld",&a,&b);
		long long r=0, k=9;

		while (k<=b)
		{r++;
		k=k*10+9;}

		T[i]=a*r;
		i++;
	}
	for (i=0;i<n;i++) {printf("%lld\n",T[i]);}
	return 0;
}


#include <stdio.h>

int main(void) {
    int t;
    scanf("%d", &t);
    while (t--) {
        int a, b;
        scanf("%d %d", &a, &b);
        int cnt = 0;
        long long int p10 = 10;
        while (p10 - 1 <= b) {
            ++cnt; p10 *= 10LL;
        }
        printf("%lld\n",  cnt * (long long int)a);
    }
}


int main()
{
  int t;
  scanf("%d",&t);
  while (t--) {
    int d;
    scanf("%d",&d);
    double a, b;
    bool found = false;
    if (d == 0) {
      found = true;
      a = 0;
      b = 0;
    } else if (d * d - 4 * d >= 0) {
      found = true;
      b = (-d + sqrt(d * d - 4 * d)) / -2.0;
      a = d / b;
    }
    if (found) {
      print("Y",a);
      print(b)
      print("\n");
    } else {
      print("N");
    }
  }
  return 0;
}


#include<stdio.h>
#include<math.h>

int main(){
int n;

long long a ,b;
scanf("%d",&n);
while(n--){

scanf("%lld %lld",&a,&b);
int count=log10(b+1);

{printf("%lld\n",a*(count));}

}
return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
typedef long long ll;
int weishu(ll b)
{
	int cnt=0;
	while(b!=0){
		cnt++;
		b/=10;
	}
	return cnt;
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		int cnt;
		cnt=weishu(b);
		ll sum=0;
		for(int j=0;j<cnt;j++){
			sum=sum*10+1;
		}
		if(b<9*sum){
			cnt--;
		}
		printf("%d\n",a*cnt);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
int weishu(int b)
{
	int cnt=0;
	while(b!=0){
		cnt++;
		b/=10;
	}
	return cnt;
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--){
		int a,b;
		scanf("%d%d",&a,&b);
		int cnt;
		if(b<9){
			cnt=0;
		}
		else{
			cnt=weishu(b);
			int sum;
			for(int j=0;j<cnt;j++){
				sum=sum*10+1;
			}
			if(b<9*sum){
				cnt--;
			}
		}
		printf("%d\n",a*cnt);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
typedef long long ll;
int weishu(ll b)
{
	int cnt=0;
	while(b!=0){
		cnt++;
		b/=10;
	}
	return cnt;
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		int cnt;
		cnt=weishu(b);
		int sum=0;
		for(int j=0;j<cnt;j++){
			sum=sum*10+1;
		}
		if(b<9*sum){
			cnt--;
		}
		printf("%d\n",a*cnt);
	}
	return 0;
}


#include<stdio.h>
typedef long long ll;
ll weishu(ll b)
{
	ll cnt=0;
	while(b!=0){
		cnt++;
		b/=10;
	}
	return cnt;
}
int main()
{
	ll t;
	scanf("%lld",&t);
	while(t--){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		ll cnt;
		cnt=weishu(b);
		ll sum=0;
		for(ll j=0;j<cnt;j++){
			sum=sum*10+1;
		}
		if(b<9*sum){
			cnt--;
		}
		printf("%lld\n",a*cnt);
	}
	return 0;
}


int main(){

    int A,B,k,i,count;
    int res;
    scanf("%d",&k);
    for(i=0; i<k; i++){
        scanf("%d %d",&A,&B);
        B=B+1;
        count = 0;
        while (B != 0) {
            B = B / 10;
            count++;
        }
        res = A*(count-1);
        printf("%d\n",res);

    }

    return 0;
}


int main(){

    long long A,B,k,count;
    long long res;
    scanf("%lld",&k);
    for(int i=0; i<k; i++){
        scanf("%lld %lld",&A,&B);
        B=B+1;
        count = 0;
        while (B != 0) {
            B = B / 10;
            count++;
        }
        res = A*(count-1);
        printf("%lld\n",res);

    }

    return 0;
}


#include<stdio.h>
int main()
{
	long long int i,k,a,b,t,z;
	scanf("%lld",&t);
	for(i=0;i<t;i++)
	{
		k=9;
		z=0;
		scanf("%lld%lld",&a,&b);
		while(b>=k)
		{
			z=z+a;
			k=k*10+9;
		}
		printf("%lld\n",z);
	}
}


#include<stdio.h>
#include<math.h>

int main()
{
   long long int t,a,b,A,B,count=0,i,y,k=0,x,z,j;

    scanf("%lld",&t);
    //printf("%lld\n",t);

    for(i=1;i<=t;i++)
    {   count=0;

        scanf("%lld %lld",&A,&B);
        //printf("%lld\n",B);

        for(a=1;a<=A;a++)
        {
            for(b=1;b<=B;b++)
            {   z=b;
                y=1;
                k=0;
                while (z!= 0)
                    {
                        z/= 10;     // n = n/10
                        ++k;
                    }
                for(j=1;j<=k;j++)
                    {
                        y=10*y;
                    }
                x=a*y;
                //printf("%lld\n",b);
                 //printf("%lld\n",x);
                if(a*b+a+b==x+b)
                  {   //printf("1\n");
                      count++;
                  }
            }
        }
        printf("%lld\n",count);
    }
    return 1;
}


#include<stdio.h>
#include<math.h>

int main()
{
   long long int t,a,b,A,B,count=0,i,y,k=0,x,z,j;
    scanf("%lld",&t);
    for(i=1;i<=t;i++)
    {   count=0;

        scanf("%lld %lld",&A,&B);

        for(j=9;j<=B;j*=11)
        {
            count++;
        }
        printf("%lld\n",A*count);

    }
return 1;
}


#include<stdio.h>
#include<math.h>

int main()
{
   long long int t,a,b,A,B,count=0,i,y,k=0,x,z,j;
    scanf("%lld",&t);
    for(i=1;i<=t;i++)
    {   count=0;

        scanf("%lld %lld",&A,&B);

        for(j=9;j<=B;j*=11)
        {
            count++;
        }
        printf("%lld",A*count);

    }
return 1;
}


#include<stdio.h>
#include<math.h>

int main()
{
   long long int t,a,b,A,B,count=0,i,y,k=0,x,z,j;
    scanf("%lld",&t);
    for(i=1;i<=t;i++)
    {   count=0;

        scanf("%lld %lld",&A,&B);

        for(j=9;j<=B;j*=11)
        {
            count++;
        }
        printf("%lld\n",A*count);

    }
return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
   long long int t,a,b,A,B,count=0,i,y,k=0,x,z,j;
    scanf("%lld",&t);
    for(i=1;i<=t;i++)
    {   count=0;

        scanf("%lld %lld",&A,&B);

        for(j=9;j<=B;j=j*10+9)
        {
            count++;
        }
        printf("%lld\n",A*count);

    }
return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
long long 	int A,B,a,b,t;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld %lld",&A,&B);
		int num_of_digits=0;
		int x=B;
		while(x>0)
		{
			num_of_digits++;
			x=x/10;
		}
		if(pow(10,num_of_digits)-1==B)
			printf("%lld\n",A*num_of_digits);
		else
			printf("%lld\n",A*(num_of_digits-1));
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
long long 	int A,B,a,b,t;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld %lld",&A,&B);
		int num_of_digits=0;
		int x=B;
		while(x>0)
		{
			num_of_digits++;
			x=x/10;
		}
		int y=1,a=num_of_digits;
		while(a--)
			y=y*10;
		if(y-1==B)
			printf("%lld\n",A*num_of_digits);
		else
			printf("%lld\n",A*(num_of_digits-1));
	}
	return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
	int T;
	while (scanf("%d", &T) != EOF)
	{
		int i;
		for (i = 0; i < T; i++)
		{
			int A, B, n;
			scanf("%d%d", &A, &B);
			n = 10;
			int b = 9;
			long long int sum = 0;
			while (b <= B)
			{
				if (b > n)
					n = n * 10;
				if (b + 1 - n == 0)
					sum = sum + 1;
				b = b+9*n;
			}
			sum = sum * A;
			printf("%lld\n", sum);
		}
	}
	return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
	int T;
	while (scanf("%d", &T) != EOF)
	{
		int i;
		for (i = 0; i < T; i++)
		{
			int A, B, n;
			scanf("%d%d", &A, &B);
			n = 10;
			int b = 9;
			long long int sum = 0;
			while (b <= B)
			{
				if (b > n)
					n = n * 10;
				if (b + 1 - n == 0)
					sum = sum + 1;
				b = b+9*n;
			}
			sum = sum * A;
			printf("%d\n", sum);
		}
	}
	return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
	int T;
	while (scanf("%d", &T) != EOF)
	{
		int i;
		for (i = 0; i < T; i++)
		{
			int A, B, n;
			scanf("%d%d", &A, &B);
			n = 10;
			int b = 9, sum = 0;
			while (b <= B)
			{
				if (b >= n)
					n = n * 10;
				if (b + 1 - n == 0)
					sum = sum + 1;
				b = b+9*n;
			}
			sum = sum * A;
			printf("%d\n", sum);
		}
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include<stdlib.h>

int main()
{
    long long A , B ,k=0,j=0,i ,n;
    char C[100];
    scanf("%lld",&n);
    for (i=1;i<=n;i++){
        scanf("%lld %lld",&A , &B);
        sprintf(C, "%lld", (B+1));
        k=strlen(C);
        printf("%lld \n",A*(k-1));
    }
return 0;
}


#include <stdio.h>

unsigned concat(unsigned x, unsigned y) {
    unsigned pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;
}

void swapMax(unsigned *a, unsigned *b) {
    unsigned aux;

    if (*a > *b) {
        aux = *a;
        *a = *b;
        *b = aux;
    }
}

int main (int argc, char* argv[]) {
    int testCases;
    unsigned c;

    scanf("%d", &testCases);

    unsigned A, B, a, b, combinations;

    int i, j, k;

    for (i = 0; i < testCases; i++) {
        scanf("%u %u", &A, &B);

        swapMax(&A, &B);

        // First round (b >= a)
        a = 1;
        b = 1;
        combinations = 0;

        for (b = 1; b <= B; b++) {
            for (a = 1; a <= b && a <= A && b % a == 0; a++) {
                c = concat(a,b);
                //printf("a: %u, b: %u, c: %u -> ", a, b, c);

                if (c % a == 0 && c % b == 0) {
                    //printf("YES\n");
                    combinations++;
                } else {
                  //  printf("NO\n");
                }
            }
        }

        // int fr = combinations;
        // printf("First round: %u\n", fr);

        // printf("SECOND ROUND\n");

        for (b = 1; b <= B; b++) {
            for (a = 1; a >= b && a <= A && a % b == 0; a++) {
                c = concat(a,b);
                printf("a: %u, b: %u, c: %u -> ", a, b, c);

                if (c % a == 0 && c % b == 0) {
                    // printf("YES\n");
                    combinations++;
                } else {
                    // printf("NO\n");
                }
            }
        }

        // printf("Second round: %u\n", combinations - fr);
        // printf("Combinations: %u\n", combinations);

        printf("%u\n", combinations);
    }
}


#include <stdio.h>
#include <math.h>

unsigned concat(unsigned long x, unsigned long y) {
    unsigned long pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;
}

unsigned long dlog(unsigned long x) {
    unsigned long result = 0;

    while (x / 10 != 0) {
        result++;
        x /= 10;
    }

    return result;
}

int main (int argc, char* argv[]) {
    int testCases;
    unsigned long c;

    scanf("%d", &testCases);

    unsigned long A, B, a, b, combinations;

    int i, j, k;

    for (i = 0; i < testCases; i++) {
        scanf("%lu %lu", &A, &B);

        printf("%lu\n", A * (unsigned long) ceil(log10((B+1)/10)));
    }
}


#include <stdio.h>
#include <math.h>

unsigned concat(unsigned long x, unsigned long y) {
    unsigned long pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;
}

unsigned long dlog(unsigned long x) {
    unsigned long result = 0;

    while (x / 10 != 0) {
        result++;
        x /= 10;
    }

    return result;
}

int main (int argc, char* argv[]) {
    int testCases;
    unsigned long c;

    scanf("%d", &testCases);

    unsigned long A, B, a, b, combinations;

    int i, j, k;

    for (i = 0; i < testCases; i++) {
        scanf("%lu %lu", &A, &B);

        // printf("frac: %lu\n", (B+1));
        // printf("log: %lf\n", log10((B+1)));
        // printf("ceil: %lf\n", floor(log10((B+1))));
        // printf("converted: %lu\n", (unsigned long) floor(log10((B+1))));

        printf("%lu\n", A * (unsigned long) floor(log10((B+1))));
    }
}


#include <stdio.h>
#include <math.h>

unsigned concat(unsigned long x, unsigned long y) {
    unsigned long pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;
}

unsigned long dlog(unsigned long x) {
    unsigned long result = 0;

    while (x / 10 != 0) {
        result++;
        x /= 10;
    }

    return result;
}

int main (int argc, char* argv[]) {
    int testCases;
    unsigned long c;

    scanf("%d", &testCases);

    unsigned long long A, B, a, b, combinations;

    int i, j, k;

    for (i = 0; i < testCases; i++) {
        scanf("%llu %llu", &A, &B);

        // printf("frac: %lu\n", (B+1));
        // printf("log: %lf\n", log10((B+1)));
        // printf("ceil: %lf\n", floor(log10((B+1))));
        // printf("converted: %lu\n", (unsigned long) floor(log10((B+1))));

        printf("%llu\n", A * (unsigned long long) floor(log10((B+1))));
    }
}


#include <stdio.h>
#include <math.h>

unsigned concat(unsigned long x, unsigned long y) {
    unsigned long pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;
}

unsigned long long dlog(unsigned long long x) {
    unsigned long long result = 0;

    while (x / 10 != 0) {
        result++;
        x /= 10;
    }

    return result;
}

int main (int argc, char* argv[]) {
    int testCases;

    scanf("%d", &testCases);

    unsigned long long A, B;

    int i;

    for (i = 0; i < testCases; i++) {
        scanf("%llu %llu", &A, &B);

        printf("%llu\n", A * dlog(B+1));
    }
}


#include <stdio.h>

unsigned concat(unsigned long x, unsigned long y) {
    unsigned long pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;
}

unsigned long dlog(unsigned long x) {
    unsigned long result = 0;

    while (x / 10 != 0) {
        result++;
        x /= 10;
    }

    return result;
}

int main (int argc, char* argv[]) {
    int testCases;
    unsigned long c;

    scanf("%d", &testCases);

    unsigned long A, B, a, b, combinations;

    int i, j, k;

    for (i = 0; i < testCases; i++) {
        scanf("%lu %lu", &A, &B);

        printf("%lu\n", A * dlog(B));
    }
}


#include <stdio.h>
#include <math.h>

unsigned concat(unsigned long x, unsigned long y) {
    unsigned long pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;
}

int main (int argc, char* argv[]) {
    int testCases;

    scanf("%d", &testCases);

    unsigned long long A, B;

    int i;

    for (i = 0; i < testCases; i++) {
        scanf("%llu %llu", &A, &B);

        printf("%llu\n", A * (unsigned long long) floor(log10((B+1))));
    }
}


#include <stdio.h>

unsigned concat(unsigned x, unsigned y) {
    unsigned pow = 10;
    while(y >= pow)
        pow *= 10;
    return x * pow + y;
}

void swapMax(unsigned *a, unsigned *b) {
    unsigned aux;

    if (*a > *b) {
        aux = *a;
        *a = *b;
        *b = aux;
    }
}

int main (int argc, char* argv[]) {
    int testCases;
    unsigned c;

    scanf("%d", &testCases);

    unsigned A, B, a, b, combinations;

    int i, j, k;

    for (i = 0; i < testCases; i++) {
        scanf("%u %u", &A, &B);

        swapMax(&A, &B);

        // First round (b >= a)
        a = 1;
        b = 1;
        combinations = 0;

        for (b = 1; b <= B; b++) {
            for (a = 1; a <= b && a <= A && b % a == 0; a++) {
                c = concat(a,b);
                //printf("a: %u, b: %u, c: %u -> ", a, b, c);

                if (c % a == 0 && c % b == 0) {
                    //printf("YES\n");
                    combinations++;
                } else {
                  //  printf("NO\n");
                }
            }
        }

        // int fr = combinations;
        // printf("First round: %u\n", fr);

        // printf("SECOND ROUND\n");

        for (b = 1; b <= B; b++) {
            for (a = 1; a >= b && a <= A && a % b == 0; a++) {
                c = concat(a,b);
                //printf("a: %u, b: %u, c: %u -> ", a, b, c);

                if (c % a == 0 && c % b == 0) {
                    // printf("YES\n");
                    combinations++;
                } else {
                    // printf("NO\n");
                }
            }
        }

        // printf("Second round: %u\n", combinations - fr);
        // printf("Combinations: %u\n", combinations);

        printf("%u\n", combinations);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        long long n,d,x,v=0;
        scanf("%lld%lld",&n,&d);
        x=log10(d)/1;
        if(d/9%10==1)
            v=1;
        printf("%lld\n",(x+v)*n);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        long long n,d,x,v=0;
        scanf("%lld%lld",&n,&d);
        x=log10(d)/1;
        if((d+1)%10==0)
            v=1;
        printf("%lld\n",(x+v)*n);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        long long n,d,x,v=0;
        scanf("%lld%lld",&n,&d);
        x=log10(d)/1;
        if(d/9%10==1&&d%9==0)
            v=1;
        printf("%lld\n",(x+v)*n);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        long long n,d,x,v=0;
        scanf("%lld%lld",&n,&d);
        x=log10(d)/1;
        if(log10(d+1)/1==log(d+1))
            v=1;
        printf("%lld\n",(x+v)*n);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        long long n,d,x;
        scanf("%lld%lld",&n,&d);
        x=log10(d)/1;
        printf("%lld\n",x*n);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        long long n,d,x,v=0;
        scanf("%lld%lld",&n,&d);
        x=log10(d)/1;
        if(d%9==0)
            v=1;
        printf("%lld\n",(x+v)*n);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int findMax(int a, int b) {
    return a > b ? a : b;
}

void test() {
    int A, B;
    scanf("%d %d", &A, &B);
    int lengthB = (int) log10((double) B);
    printf("%d\n", A * lengthB);
}

int main ()
{
    int t;
    scanf("%d", &t);
    while(t--)
        test();

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int findMax(int a, int b) {
    return a > b ? a : b;
}

void test() {
    int A, B;
    scanf("%d %d", &A, &B);
    int lengthB = (int) log10((double) B + 1);
    printf("%d\n", A * lengthB);
}

int main ()
{
    int t;
    scanf("%d", &t);
    while(t--)
        test();

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

typedef long long int LL;

void test() {
    LL A, B;
    scanf("%lld %lld", &A, &B);
    LL lengthB = (LL) log10((double) B + 1);
    printf("%lld\n", A * lengthB);
}

int main ()
{
    int t;
    scanf("%d", &t);
    while(t--)
        test();

    return 0;
}


#include <stdio.h>
#include <math.h>

int len(int a)
{
	int i = 0;
	while (a)
	{
		i++;
		a /= 10;
	}
	return i;
}

void solve()
{
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", a * (len(b + 1) - 1));
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
		solve();
	return 0;
}


#include <stdio.h>
#include <math.h>

long long len(long long a)
{
	long long i = 0;
	while (a)
	{
		i++;
		a /= 10;
	}
	return i;
}

void solve()
{
	long long a, b;
	scanf("%lld%lld", &a, &b);
	printf("%lld\n", (long long)(a * (len(b + 1) - 1)));
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
		solve();
	return 0;
}


#include <stdio.h>
#include <math.h>

int len(long long a)
{
	int i = 0;
	while (a)
	{
		i++;
		a /= 10;
	}
	return i;
}

void solve()
{
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%lld\n", (long long)(a * (len(b + 1) - 1)));
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
		solve();
	return 0;
}


#include <stdio.h>
#include <math.h>

long long conc(int x, int y)
{
	long long pow = 10;
	while(y >= pow)
		pow *= 10;
	return x * pow + y;
}

int len(int a)
{
	int i = 0;
	while (a)
	{
		i++;
		a /= 10;
	}
	return i;
}

void solve()
{
	int a, b;
	scanf("%d%d", &a, &b);
	long long c = 0;
	for (int j = 1;j <= b;j++)
	{
		if (j + 1 == pow(10, len(j)))
			c++;
	}
	printf("%lld\n", c * a);
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
		solve();
	return 0;
}


#include <stdio.h>
#include <math.h>

int len(int a)
{
	int i = 0;
	while (a)
	{
		i++;
		a /= 10;
	}
	return i;
}

void solve()
{
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%lld\n", (long long)(a * (len(b + 1) - 1)));
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
		solve();
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
int n;
 long long a ,b;
scanf("%d",&n);
while(n--){
scanf("%lld %lld",&a,&b);
int count=log10(b+1);
{printf("%lld\n",a*(count));}
}
return 0;
}


#include<stdio.h>

int main()
{
    long long int t, a, b, p, c;
    scanf("%lld", &t);
    while(t--)
    {
        scanf("%lld%lld", &a, &b);
        p=9;
        c=0;
        if(b<9)
            printf("0\n");
        else
        {
            while(p<=b)
            {
                c+=a;
                p=p*10+9;
            }
            printf("%lld\n", c);
        }
    }
    return 0;
}


#include <stdio.h>
int main()
{
	int t;
	scanf("%d",&t);
	long long int a,b;
	while(t--)
	{
		scanf("%lld %lld",&a,&b);
		long long int j=9;
		long long int cnt=0;
		while(j<=b)
		{
			j=j*10+9;
			cnt++;
		}
		printf("%lld\n",cnt*a);
	}
	return 0;
}


#include <stdio.h>
int main()
{
	int t;
	int a, b;
	scanf("%d", &t);
	while (t--)
	{
		int i = 0;
		scanf("%d %d", &a, &b);
		int d = b;
		while (b != 0)
		{
			i++;
			b /= 10;
		}
		int s = (i-1) * a;
		int m = i-1;
		int c = 9;
		while (m--)
		{
			c = c * 10 + 9;
		}
		printf("%d\n", c);
		if (d == c)
		{
			printf("%d\n", i * a);
		}
		else
			printf("%d\n", s);
	}
	return 0;
}


#include <stdio.h>
int main()
{
	int t;
	int a, b;
	scanf("%d", &t);
	while (t--)
	{
		int i = 0;
		scanf("%d %d", &a, &b);
		int d = b;
		while (b != 0)
		{
			i++;
			b /= 10;
		}
		int e;
		int c = 9;
		int e1 = i;
		i = i - 1;
		while (i--)
		{
			c = c * 10 + 9;
		}
		int c1 = c % 10;
		if (b >= c1 && b < c)
			printf("%d\n", (e1 - 1) * a);
		else
			printf("%d\n", e1 * a);
	}
	return 0;
}


#include <stdio.h>
int main()
{
	int t;
	int a, b;
	scanf("%d", &t);
	while (t--)
	{
		int i = 0;
		scanf("%d %d", &a, &b);
		int d = b;
		while (b != 0)
		{
			i++;
			b /= 10;
		}
		int s = (i-1) * a;
		int m = i-1;
		int c = 9;
		while (m--)
		{
			c = c * 10 + 9;
		}
		if (d == c)
		{
			printf("%d\n", i * a);
		}
		else
			printf("%d\n", s);
	}
	return 0;
}


#include <stdio.h>
int main()
{
	int t;
	scanf("%d",&t);
	int a,b;
	while(t--)
	{
		scanf("%d %d",&a,&b);
		int j=9;
		int cnt=0;
		while(j<=b)
		{
			j=j*10+9;
			cnt++;
		}
		printf("%d\n",cnt*a);
	}
	return 0;
}


#include <stdio.h>
int main()
{
	int t;
	int a, b;
	scanf("%d", &t);
	while (t--)
	{
		int i = 0;
		scanf("%d %d", &a, &b);
		while (b != 0)
		{
			i++;
			b /= 10;
		}
		int s = (i-1) * a;
		printf("%d\n", s);
	}
	return 0;
}


#include <stdio.h>
#include <math.h>

int  power(int b, int p)
{
	int r;

	r = 1;
	while (p--)
		r *= b;
	return (r);
}

int main()
{
	int t;
	scanf("%d", &t);

	while (t--)
	{
		int a;
		int b;

		scanf("%d", &a);
		scanf("%d", &b);

		if (b < a)
		{
			int temp = a;
			a = b;
			b = a;
		}
		long long r = log10(b);
		if (b == power(10, log10(b) + 1) - 1)
			r++;
		printf("%lld\n", r * a);
	}
	return (0);
}


#include <stdio.h>
#include <math.h>

int  power(int b, int p)
{
	int r;

	r = 1;
	while (p--)
		r *= b;
	return (r);
}

int main()
{
	int t;
	scanf("%d", &t);

	while (t--)
	{
		int a;
		int b;

		scanf("%d", &a);
		scanf("%d", &b);

		long long r = log10(b);
		if (b == power(10, log10(b) + 1) - 1)
			r++;
		printf("%lld\n", r * a);
	}
	return (0);
}


	import java.math.BigInteger;
		import java.sql.Array;
		import java.util.ArrayList;
			import java.util.Arrays;
			import java.util.Collection;
			import java.util.Collections;
			import java.util.Comparator;
			import java.util.HashMap;
			import java.util.InputMismatchException;
			import java.util.Iterator;
			import java.util.LinkedHashSet;
			import java.util.LinkedList;
			import java.util.List;
			import java.util.Map;
			import java.util.Map.Entry;
			import java.util.PriorityQueue;
			import java.util.Queue;
			import java.util.Scanner;
			import java.util.Set;
			import java.util.Stack;
			import java.io.BufferedReader;
			import java.io.IOException;
			import java.io.InputStream;
			import java.io.InputStreamReader;
			import java.util.Scanner;
			import java.util.StringTokenizer;
			import java.util.TreeMap;
			import java.util.TreeSet;

			public class Main {

				static InputReader rd=new InputReader(System.in);
				public static void main(String[] args) {

				int t=rd.readInt();

				while(t-->0) {

					int n=rd.readInt();

					ArrayList<Integer> A=new ArrayList<Integer>();
					ArrayList<Integer> B=new ArrayList<Integer>();
					ArrayList<Integer> C=new ArrayList<Integer>();

					int a[]=new int[n];
					for(int i=0;i<n;i++)A.add(rd.readInt());
					for(int i=0;i<n;i++)B.add(rd.readInt());
					for(int i=0;i<n;i++)C.add(rd.readInt());

					int k=0;
					HashMap<Integer, Integer> map=new HashMap<Integer, Integer>();

					for(int i=0;i<n;i++) {
						a[i]=-1;
						if(!map.containsKey(A.get(i)))map.put(A.get(i), 1);
						else map.put(A.get(i), map.get(A.get(i))+1);

					}

					for(int i=0;i<n;i++) {

						if(!map.containsKey(B.get(i)))map.put(B.get(i), 1);
						else map.put(B.get(i), map.get(B.get(i))+1);

					}
					for(int i=0;i<n;i++) {

						if(!map.containsKey(C.get(i)))map.put(C.get(i), 1);
						else map.put(C.get(i), map.get(C.get(i))+1);
					}

					//System.out.println(map);

					for(int i:map.keySet()) {
						//System.out.println(map.get(i));
						int p=map.get(i);
						for(int j=0;j<n;j++) {

							if(a[j]==-1) {
								a[j]=i;
								p--;
							}

							else if(j!=0&&a[j]==a[j-1]) {
								a[j]=i;
								p--;
							}

							if(p==0)break;
						}

					}

					for(int i=0;i<n;i++) {
						System.out.print(a[i]+" ");
					}

					System.out.println();
				}

				}

				static class Helper{
					char val;int index;
					public Helper(char val,int index) {

						this.val=val;
						this.index=index;
						// TODO Auto-generated constructor stub
					}
				}

				  static class InputReader {
				        private InputStream stream;
				        private byte[] buf = new byte[1024];
				        private int curChar;
				        private int numChars;
				        private SpaceCharFilter filter;

				        public InputReader(InputStream stream) {
				            this.stream = stream;
				        }

				        public int read() {
				            if (numChars == -1)
				                throw new InputMismatchException();
				            if (curChar >= numChars) {
				                curChar = 0;
				                try {
				                    numChars = stream.read(buf);
				                } catch (IOException e) {
				                    throw new InputMismatchException();
				                }
				                if (numChars <= 0)
				                    return -1;
				            }
				            return buf[curChar++];
				        }

				        public int readInt() {
				            int c = read();
				            while (isSpaceChar(c))
				                c = read();
				            int sgn = 1;
				            if (c == '-') {
			    sgn = -1;
			    c = read();
			}
			int res = 0;
			do {
			    if (c < '0' || c > '9')
			        throw new InputMismatchException();
			    res *= 10;
			    res += c - '0';
			        c = read();
			    } while (!isSpaceChar(c));
			    return res * sgn;
			}

			public String readString() {
			    int c = read();
			    while (isSpaceChar(c))
			        c = read();
			    StringBuilder res = new StringBuilder();
			    do {
			        res.appendCodePoint(c);
			        c = read();
			    } while (!isSpaceChar(c));
			    return res.toString();
			}

			public boolean isSpaceChar(int c) {
			    if (filter != null)
			        return filter.isSpaceChar(c);
			    return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				        }

				        public String next() {
				            return readString();
				        }

				    }

				  public interface SpaceCharFilter {
				        public boolean isSpaceChar(int ch);
				    }

			}


	import java.math.BigInteger;
		import java.sql.Array;
		import java.util.ArrayList;
			import java.util.Arrays;
			import java.util.Collection;
			import java.util.Collections;
			import java.util.Comparator;
			import java.util.HashMap;
			import java.util.InputMismatchException;
			import java.util.Iterator;
			import java.util.LinkedHashSet;
			import java.util.LinkedList;
			import java.util.List;
			import java.util.Map;
			import java.util.Map.Entry;
			import java.util.PriorityQueue;
			import java.util.Queue;
			import java.util.Scanner;
			import java.util.Set;
			import java.util.Stack;
			import java.io.BufferedReader;
			import java.io.IOException;
			import java.io.InputStream;
			import java.io.InputStreamReader;
			import java.util.Scanner;
			import java.util.StringTokenizer;
			import java.util.TreeMap;
			import java.util.TreeSet;

			public class Main {

				static InputReader rd=new InputReader(System.in);
				public static void main(String[] args) {

				int t=rd.readInt();

				while(t-->0) {

					int n=rd.readInt();

					ArrayList<Integer> A=new ArrayList<Integer>();
					ArrayList<Integer> B=new ArrayList<Integer>();
					ArrayList<Integer> C=new ArrayList<Integer>();

					int a[]=new int[n];
					for(int i=0;i<n;i++)A.add(rd.readInt());
					for(int i=0;i<n;i++)B.add(rd.readInt());
					for(int i=0;i<n;i++)C.add(rd.readInt());

					int k=0;
					HashMap<Integer, Integer> map=new HashMap<Integer, Integer>();
					a[k++]=A.get(0);
					for(int i=1;i<n;i++) {

							boolean pl=false;
							if(a[i-1]!=A.get(i)) {
								if(i==n-1&&A.get(i)==a[0])
								{
									k++;
								}
								else{a[i]=A.get(i);
								pl=true;}

							}

							 if(a[i-1]!=B.get(i)&&!pl) {
								if(i==n-1&&B.get(i)==a[0])
								{
									k++;
								}
								else{a[i]=B.get(i);
								pl=true;}

							}
							 if(a[i-1]!=C.get(i)&&!pl) {
								 if(i==n-1&&C.get(i)==a[0])
									{
										k++;
									}
									else{a[i]=C.get(i);
									pl=true;}

							}

					}

					for(int i=0;i<n;i++) {
						System.out.print(a[i]+" ");
					}

					System.out.println();
				}

				}

				static class Helper{
					char val;int index;
					public Helper(char val,int index) {

						this.val=val;
						this.index=index;
						// TODO Auto-generated constructor stub
					}
				}

				  static class InputReader {
				        private InputStream stream;
				        private byte[] buf = new byte[1024];
				        private int curChar;
				        private int numChars;
				        private SpaceCharFilter filter;

				        public InputReader(InputStream stream) {
				            this.stream = stream;
				        }

				        public int read() {
				            if (numChars == -1)
				                throw new InputMismatchException();
				            if (curChar >= numChars) {
				                curChar = 0;
				                try {
				                    numChars = stream.read(buf);
				                } catch (IOException e) {
				                    throw new InputMismatchException();
				                }
				                if (numChars <= 0)
				                    return -1;
				            }
				            return buf[curChar++];
				        }

				        public int readInt() {
				            int c = read();
				            while (isSpaceChar(c))
				                c = read();
				            int sgn = 1;
				            if (c == '-') {
			    sgn = -1;
			    c = read();
			}
			int res = 0;
			do {
			    if (c < '0' || c > '9')
			        throw new InputMismatchException();
			    res *= 10;
			    res += c - '0';
			        c = read();
			    } while (!isSpaceChar(c));
			    return res * sgn;
			}

			public String readString() {
			    int c = read();
			    while (isSpaceChar(c))
			        c = read();
			    StringBuilder res = new StringBuilder();
			    do {
			        res.appendCodePoint(c);
			        c = read();
			    } while (!isSpaceChar(c));
			    return res.toString();
			}

			public boolean isSpaceChar(int c) {
			    if (filter != null)
			        return filter.isSpaceChar(c);
			    return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				        }

				        public String next() {
				            return readString();
				        }

				    }

				  public interface SpaceCharFilter {
				        public boolean isSpaceChar(int ch);
				    }

			}


	import java.math.BigInteger;
		import java.sql.Array;
		import java.util.ArrayList;
			import java.util.Arrays;
			import java.util.Collection;
			import java.util.Collections;
			import java.util.Comparator;
			import java.util.HashMap;
			import java.util.InputMismatchException;
			import java.util.Iterator;
			import java.util.LinkedHashSet;
			import java.util.LinkedList;
			import java.util.List;
			import java.util.Map;
			import java.util.Map.Entry;
			import java.util.PriorityQueue;
			import java.util.Queue;
			import java.util.Scanner;
			import java.util.Set;
			import java.util.Stack;
			import java.io.BufferedReader;
			import java.io.IOException;
			import java.io.InputStream;
			import java.io.InputStreamReader;
			import java.util.Scanner;
			import java.util.StringTokenizer;
			import java.util.TreeMap;
			import java.util.TreeSet;

			public class Main {

				static InputReader rd=new InputReader(System.in);
				public static void main(String[] args) {

				int t=rd.readInt();

				while(t-->0) {

					int n=rd.readInt();

					ArrayList<Integer> A=new ArrayList<Integer>();
					ArrayList<Integer> B=new ArrayList<Integer>();
					ArrayList<Integer> C=new ArrayList<Integer>();

					int a[]=new int[n];
					for(int i=0;i<n;i++)A.add(rd.readInt());
					for(int i=0;i<n;i++)B.add(rd.readInt());
					for(int i=0;i<n;i++)C.add(rd.readInt());

					int k=0;
					HashMap<Integer, Integer> map=new HashMap<Integer, Integer>();

					for(int i=0;i<n;i++) {
						a[i]=-1;
						if(!map.containsKey(A.get(i)))map.put(A.get(i), 1);
						else map.put(A.get(i), map.get(A.get(i))+1);

					}

					for(int i=0;i<n;i++) {

						if(!map.containsKey(B.get(i)))map.put(B.get(i), 1);
						else map.put(B.get(i), map.get(B.get(i))+1);

					}
					for(int i=0;i<n;i++) {

						if(!map.containsKey(C.get(i)))map.put(C.get(i), 1);
						else map.put(C.get(i), map.get(C.get(i))+1);
					}

					//System.out.println(map);

					for(int i:map.keySet()) {
						//System.out.println(map.get(i));
						int p=map.get(i);
						for(int j=0;j<n;j++) {

							if(a[j]==-1) {
								if(j==n-1&&a[0]==i)continue;

								a[j]=i;
								p--;
							}

							else if(j!=0&&a[j]==a[j-1]) {

								if(j==n-1&&a[0]==i)continue;
								//System.out.println(j);
							//	System.out.println(i);
								a[j]=i;
								p--;
							}

							if(p==0)break;
						}

					}

					for(int i=0;i<n;i++) {
						System.out.print(a[i]+" ");
					}

					System.out.println();
				}

				}

				static class Helper{
					char val;int index;
					public Helper(char val,int index) {

						this.val=val;
						this.index=index;
						// TODO Auto-generated constructor stub
					}
				}

				  static class InputReader {
				        private InputStream stream;
				        private byte[] buf = new byte[1024];
				        private int curChar;
				        private int numChars;
				        private SpaceCharFilter filter;

				        public InputReader(InputStream stream) {
				            this.stream = stream;
				        }

				        public int read() {
				            if (numChars == -1)
				                throw new InputMismatchException();
				            if (curChar >= numChars) {
				                curChar = 0;
				                try {
				                    numChars = stream.read(buf);
				                } catch (IOException e) {
				                    throw new InputMismatchException();
				                }
				                if (numChars <= 0)
				                    return -1;
				            }
				            return buf[curChar++];
				        }

				        public int readInt() {
				            int c = read();
				            while (isSpaceChar(c))
				                c = read();
				            int sgn = 1;
				            if (c == '-') {
			    sgn = -1;
			    c = read();
			}
			int res = 0;
			do {
			    if (c < '0' || c > '9')
			        throw new InputMismatchException();
			    res *= 10;
			    res += c - '0';
			        c = read();
			    } while (!isSpaceChar(c));
			    return res * sgn;
			}

			public String readString() {
			    int c = read();
			    while (isSpaceChar(c))
			        c = read();
			    StringBuilder res = new StringBuilder();
			    do {
			        res.appendCodePoint(c);
			        c = read();
			    } while (!isSpaceChar(c));
			    return res.toString();
			}

			public boolean isSpaceChar(int c) {
			    if (filter != null)
			        return filter.isSpaceChar(c);
			    return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				        }

				        public String next() {
				            return readString();
				        }

				    }

				  public interface SpaceCharFilter {
				        public boolean isSpaceChar(int ch);
				    }

			}


import java.util.*;
import java.io.*;
import java.util.Arrays;
public class Main {

	public static void main (String [] args) throws IOException

	{
		Scanner s=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		StringBuilder sb=new StringBuilder();

		int t=s.nextInt();
		while (t-->0)
		{
			int n=s.nextInt();
			int []a=new int [n];
			int []b=new int [n];
			int []c=new int [n];
			for (int i=0; i<n;i++)
				a[i]=s.nextInt();
			for (int i=0; i<n;i++)
				b[i]=s.nextInt();
			for (int i=0; i<n;i++)
				c[i]=s.nextInt();

			int []ans=new int [n];
			int num=a[0];
			ans[0]=a[0];
			for (int i=1; i<n;i++)
			{
				if (a[i]!=num)
				{
					ans[i]=a[i];
					num=a[i];
				}
				else if (b[i]!=num)
				{
					ans[i]=b[i];
					num=b[i];
				}
			}
			for (int i=0; i<n;i++)
			{
				if (i!=n-1)
					pw.print(ans[i]+" ");
				else
				{
					if (a[i]!=ans[i-1] &&a[i]!=ans[0])
						pw.println(a[i]+" ");
					else if (b[i]!=ans[i-1] &&b[i]!=ans[0])
						pw.println(b[i]+" ");
					else
						pw.println(c[i]+" ");
				}
			}

		}

	pw.flush();

	}

	public static void shuffle(int[] a)
	{
		int n = a.length;
		for(int i = 0; i < n; i++)
		{
			int r = i + (int)(Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}

	/*

	 try {
		    Thread.sleep(2000);
		} catch(InterruptedException ex) {
		    Thread.currentThread().interrupt();
		}

	 */

	static class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}

	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}

}
}


import java.util.*;
import java.io.*;
import java.util.Arrays;
public class Main {

	public static void main (String [] args) throws IOException

	{
		Scanner s=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		StringBuilder sb=new StringBuilder();

		int t=s.nextInt();
		while (t-->0)
		{
			int n=s.nextInt();
			int []a=new int [n];
			int []b=new int [n];
			int []c=new int [n];
			for (int i=0; i<n;i++)
				a[i]=s.nextInt();
			for (int i=0; i<n;i++)
				b[i]=s.nextInt();
			for (int i=0; i<n;i++)
				c[i]=s.nextInt();
			pw.print(a[0]+" ");
			int num=a[0];
			for (int i=1; i<n;i++)
			{
				if (a[i]!=num)
				{
					pw.print(a[i]+" ");
					num=a[i];
				}
				else if (b[i]!=num)
				{
					pw.print(b[i]+" ");
					num=b[i];
				}
			}
			pw.println();

		}

	pw.flush();

	}

	public static void shuffle(int[] a)
	{
		int n = a.length;
		for(int i = 0; i < n; i++)
		{
			int r = i + (int)(Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}

	/*

	 try {
		    Thread.sleep(2000);
		} catch(InterruptedException ex) {
		    Thread.currentThread().interrupt();
		}

	 */

	static class Scanner
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}

	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}

	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}

	public boolean ready() throws IOException {return br.ready();}

}
}


import java.util.*;
import java.io.*;
import java.lang.*;
public class CircleColoring{
	public static void main(String args[])throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while(t-->0){
			int seq = Integer.parseInt(br.readLine());
			String a[] = br.readLine().trim().split("\\s+");
			String b[] = br.readLine().trim().split("\\s+");
			String c[] = br.readLine().trim().split("\\s+");
			String p[] = new String[seq];
			p[0]=a[0];
			for(int i=0;i<seq-1;i++){
				if(i!=seq-2){
					if(!p[i].equals(a[i+1])){
						p[i+1]=a[i+1];
					}
					else if(!p[i].equals(b[i+1])){
						p[i+1]=b[i+1];
					}
					else{
						p[i+1]=c[i+1];
					}
				}
				else{
					if(!p[i].equals(a[i+1]) && !a[i+1].equals(p[0])){
						p[i+1]=a[i+1];
					}
					else if(!p[i].equals(b[i+1]) && !a[i+1].equals(p[0])){
						p[i+1]=b[i+1];
					}
					else{
						p[i+1]=c[i+1];
					}
				}
			}
			for(int i=0;i<seq-1;i++){
				System.out.print(p[i]+" ");
			}
			System.out.println(p[seq-1]);
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.*;
public class CircleColoring{
	public static void main(String args[])throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while(t-->0){
			int seq = Integer.parseInt(br.readLine());
			String a[] = br.readLine().trim().split("\\s+");
			String b[] = br.readLine().trim().split("\\s+");
			String c[] = br.readLine().trim().split("\\s+");
			String p[] = new String[seq];
			p[0]=a[0];
			for(int i=0;i<seq-1;i++){
				if(i!=seq-2){
					if(!p[i].equals(a[i+1])){
						p[i+1]=a[i+1];
					}
					else if(!p[i].equals(b[i+1])){
						p[i+1]=b[i+1];
					}
					else{
						p[i+1]=c[i+1];
					}
				}
				else{
					if(!p[i].equals(a[i+1]) && !a[i+1].equals(p[0])){
						p[i+1]=a[i+1];
					}
					else if(!p[i].equals(b[i+1]) && !b[i+1].equals(p[0])){
						p[i+1]=b[i+1];
					}
					else{
						p[i+1]=c[i+1];
					}
				}
			}
			for(int i=0;i<seq-1;i++){
				System.out.print(p[i]+" ");
			}
			System.out.println(p[seq-1]);
		}
	}
}


import java.util.*;
import java.io.*;
import java.lang.*;
public class CircleColoring{
	public static void main(String args[])throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while(t-->0){
			int seq = Integer.parseInt(br.readLine());
			String a[] = br.readLine().trim().split("\\s+");
			String b[] = br.readLine().trim().split("\\s+");
			String c[] = br.readLine().trim().split("\\s+");
			String p[] = new String[seq];
			p[0]=a[0];
			for(int i=0;i<seq-1;i++){
				if(i!=seq-1){
					if(!p[i].equals(a[i+1])){
						p[i+1]=a[i+1];
						}
					else if(!p[i].equals(b[i+1])){
						p[i+1]=b[i+1];
					}
					else{
						p[i+1]=c[i+1];
					}
				}
				else{
					if(!p[i].equals(a[i+1]) && !p[i].equals(a[0])){
						p[i+1]=a[i+1];
						}
					else if(!p[i].equals(b[i+1]) && !p[i].equals(a[0])){
						p[i+1]=b[i+1];
					}
					else{
						p[i+1]=c[i+1];
					}
				}
			}
			for(int i=0;i<seq-1;i++){
				System.out.print(p[i]+" ");
			}
			System.out.println(p[seq-1]);
		}
	}
}


import java.util.*;
import java.io.*;

public class Circle_Coloring {

	static int mod = (int) (1e9 + 7);

	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while (t-- > 0) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int n = Integer.parseInt(st.nextToken());
			int a[] = new int[n];
			st = new StringTokenizer(br.readLine());
			StringTokenizer s1 = new StringTokenizer(br.readLine());
			StringTokenizer s2 = new StringTokenizer(br.readLine());
			int c=0;
			for (int i = 0; i < n; i++) {
				if(c==n) break;
				int x = Integer.parseInt(st.nextToken());
				System.out.print(x+" ");
				++c;
				if(c==n) break;
				int y = Integer.parseInt(s1.nextToken());
				System.out.print(y+" ");
				++c;
				if(c==n) break;
				int z = Integer.parseInt(s2.nextToken());
				System.out.print(z+" ");
				++c;
				if(c==n) break;
			}
			System.out.println();
		}
	}

	static class CP {

		static boolean isPrime(long n) {
			if (n <= 1)
				return false;
			if (n == 2 || n == 3)
				return true;
			if (n % 2 == 0 || n % 3 == 0)
				return false;
			for (int i = 5; i * i <= n; i += 6) {
				if (n % i == 0 || n % (i + 2) == 0)
					return false;
			}
			return true;
		}

		static long binary_Expo(long a, long b) { // calculating a^b
			long res = 1;
			while (b != 0) {
				if ((b & 1) == 1) {
					res *= a;
					--b;
				}
				a *= a;
				b /= 2;
			}
			return res;
		}

		static long Modular_Expo(long a, long b) {
			long res = 1;
			while (b != 0) {
				if ((b & 1) == 1) {
					res = (res * a) % mod;
					--b;
				}
				a = (a * a) % mod;
				b /= 2;
			}
			return res;
		}

		static int i_gcd(int a, int b) {// iterative way to calculate gcd.
			while (true) {
				if (b == 0)
					return a;
				int c = a;
				a = b;
				b = c % b;
			}
		}

		static long gcd(long a, long b) {// here b is the remainder
			if (b == 0)
				return a; //because each time b will divide a.
			return gcd(b, a % b);
		}

		static long ceil_div(long a, long b) { // a numerator b denominator
			return (a + b - 1) / b;
		}

		static int getIthBitFromInt(int bits, int i) {
			return (bits >> (i - 1)) & 1;
		}

		static int upper_Bound(int a[], int x) {//closest to the left+1
			int l = -1, r = a.length;
			while (l + 1 < r) {
				int m = (l + r) >>> 1;
				if (a[m] <= x)
					l = m;
				else
					r = m;
			}
			return l + 1;
		}

		static int lower_Bound(int a[], int x) {//closest to the right
			int l = -1, r = a.length;
			while (l + 1 < r) {
				int m = (l + r) >>> 1;
				if (a[m] >= x)
					r = m;
				else
					l = m;
			}
			return r;
		}

		static void sort(int a[]) {//heap sort
			PriorityQueue<Integer> q = new PriorityQueue<>();
			for (int i = 0; i < a.length; i++)
				q.add(a[i]);
			for (int i = 0; i < a.length; i++)
				a[i] = q.poll();
		}

	}
}


import java.util.*;
import java.io.*;

public class Circle_Coloring {

	static int mod = (int) (1e9 + 7);

	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while (t-- > 0) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int n = Integer.parseInt(st.nextToken());
			int a[] = new int[n];
			st = new StringTokenizer(br.readLine());
			StringTokenizer s1 = new StringTokenizer(br.readLine());
			StringTokenizer s2 = new StringTokenizer(br.readLine());
			int c=0;
			Set<Integer> h=new HashSet<>();
			for(int i=0; i<n; i++) {
				int x = Integer.parseInt(st.nextToken());
				int y = Integer.parseInt(s1.nextToken());
				int z = Integer.parseInt(s2.nextToken());
				if(i==0) a[i]=x;
				else if(i<n-1){
					if(a[i-1]!=x) {a[i]=x;continue;}
					else if(a[i-1]!=y) {a[i]=y;continue;}
					else if(a[i-1]!=z) {a[i]=z;continue;}
				}else if(i==n-1) {
					if(a[i-1]!=x && a[0]!=x) {a[i]=x;continue;}
					if(a[i-1]!=y && a[0]!=y) {a[i]=y;continue;}
					if(a[i-1]!=z && a[0]!=z) {a[i]=z;continue;}
				}
			}
			for(int e: a) System.out.print(e+" ");
			System.out.println();
		}
	}

	static class CP {

		static boolean isPrime(long n) {
			if (n <= 1)
				return false;
			if (n == 2 || n == 3)
				return true;
			if (n % 2 == 0 || n % 3 == 0)
				return false;
			for (int i = 5; i * i <= n; i += 6) {
				if (n % i == 0 || n % (i + 2) == 0)
					return false;
			}
			return true;
		}

		static long binary_Expo(long a, long b) { // calculating a^b
			long res = 1;
			while (b != 0) {
				if ((b & 1) == 1) {
					res *= a;
					--b;
				}
				a *= a;
				b /= 2;
			}
			return res;
		}

		static long Modular_Expo(long a, long b) {
			long res = 1;
			while (b != 0) {
				if ((b & 1) == 1) {
					res = (res * a) % mod;
					--b;
				}
				a = (a * a) % mod;
				b /= 2;
			}
			return res;
		}

		static int i_gcd(int a, int b) {// iterative way to calculate gcd.
			while (true) {
				if (b == 0)
					return a;
				int c = a;
				a = b;
				b = c % b;
			}
		}

		static long gcd(long a, long b) {// here b is the remainder
			if (b == 0)
				return a; //because each time b will divide a.
			return gcd(b, a % b);
		}

		static long ceil_div(long a, long b) { // a numerator b denominator
			return (a + b - 1) / b;
		}

		static int getIthBitFromInt(int bits, int i) {
			return (bits >> (i - 1)) & 1;
		}

		static int upper_Bound(int a[], int x) {//closest to the left+1
			int l = -1, r = a.length;
			while (l + 1 < r) {
				int m = (l + r) >>> 1;
				if (a[m] <= x)
					l = m;
				else
					r = m;
			}
			return l + 1;
		}

		static int lower_Bound(int a[], int x) {//closest to the right
			int l = -1, r = a.length;
			while (l + 1 < r) {
				int m = (l + r) >>> 1;
				if (a[m] >= x)
					r = m;
				else
					l = m;
			}
			return r;
		}

		static void sort(int a[]) {//heap sort
			PriorityQueue<Integer> q = new PriorityQueue<>();
			for (int i = 0; i < a.length; i++)
				q.add(a[i]);
			for (int i = 0; i < a.length; i++)
				a[i] = q.poll();
		}

	}
}


import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br  =new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		while(t-->0)
		{
			int n = Integer.parseInt(br.readLine());
			int[] a = new int [n];
			int[] b = new int [n];
			int[] c = new int [n];
			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int i = 0; i < a.length; i++) {
				a[i]=Integer.parseInt(st.nextToken());
			}
			st = new StringTokenizer(br.readLine());
			for (int i = 0; i < b.length; i++) {
				b[i]=Integer.parseInt(st.nextToken());
			}
			st = new StringTokenizer(br.readLine());
			for (int i = 0; i < c.length; i++) {
				c[i]=Integer.parseInt(st.nextToken());
			}
			int[] p = new int[n];
			for (int i = 0; i < p.length; i++) {
				if((i>0 && p[i-1]!=a[i] || i==0)&& (i==n-1 || a[i]!=a[i+1]||a[i]!=b[i+1]||a[i]!=c[i+1]))
				{
					p[i]=a[i];
				}
				else if((i>0 && p[i-1]!=b[i] || i==0)&& (i==n-1 || b[i]!=b[i+1]||b[i]!=b[i+1]||b[i]!=c[i+1]))
				{
					p[i]=b[i];
				}
				else if((i>0 && p[i-1]!=c[i] || i==0)&& (i==n-1 || c[i]!=a[i+1]||c[i]!=b[i+1]||c[i]!=c[i+1]))
				{
					p[i]=c[i];
				}
			}
			for (int i = 0; i < p.length; i++) {
				pw.print(p[i] + " ");
			}
			pw.println();
		}
		pw.close();
	}
}


import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br  =new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		while(t-->0)
		{
			int n = Integer.parseInt(br.readLine());
			int[] a = new int [n];
			int[] b = new int [n];
			int[] c = new int [n];
			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int i = 0; i < a.length; i++) {
				a[i]=Integer.parseInt(st.nextToken());
			}
			st = new StringTokenizer(br.readLine());
			for (int i = 0; i < b.length; i++) {
				b[i]=Integer.parseInt(st.nextToken());
			}
			st = new StringTokenizer(br.readLine());
			for (int i = 0; i < c.length; i++) {
				c[i]=Integer.parseInt(st.nextToken());
			}
			int[] p = new int[n];
			for (int i = 0; i < p.length; i++) {
				if(i!=n-1)
				{
					int prev=i==0?n-1:i-1;
					int next=i==n-1?0:i+1;
					if((i>0 && p[prev]!=a[i] || i==0)&& (a[i]!=a[next]||a[i]!=b[next]||a[i]!=c[next]))
					{
						p[i]=a[i];
					}
					else if((i>0 && p[prev]!=b[i] || i==0)&& (b[i]!=b[next]||b[i]!=b[next]||b[i]!=c[next]))
					{
						p[i]=b[i];
					}
					else if((i>0 && p[prev]!=c[i] || i==0)&& (c[i]!=a[next]||c[i]!=b[next]||c[i]!=c[next]))
					{
						p[i]=c[i];
					}
				}
				else
				{
					if(p[n-2]!=a[i] && p[0]!=a[i])
					{
						p[i]=a[i];
					}
					else if(p[n-2]!=b[i] && p[0]!=b[i])
					{
						p[i]=b[i];
					}
					else if(p[n-2]!=c[i] && p[0]!=c[i])
					{
						p[i]=c[i];
					}
				}

			}
			for (int i = 0; i < p.length; i++) {
				pw.print(p[i] + " ");
			}
			pw.println();
		}
		pw.close();
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rohan Gandhi
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        ACircleColoring solver = new ACircleColoring();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class ACircleColoring {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int[] a = new int[n], b = new int[n], c = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = in.nextInt();
            for (int i = 0; i < n; i++)
                b[i] = in.nextInt();
            for (int i = 0; i < n; i++)
                c[i] = in.nextInt();

            int ans[] = new int[n];
            for (int i = 0; i < n; i++) {
                if ((i == 0 || a[i] != ans[i - 1]) && (i == n - 1 || a[i] != a[i + 1] || a[i] != b[i + 1] || a[i] != c[i + 1]) && (i < n - 1 || a[i] != ans[0]))
                    ans[i] = a[i];
                else if ((i == 0 || b[i] != ans[i - 1]) && (i == n - 1 || b[i] != a[i + 1] || b[i] != b[i + 1] || b[i] != c[i + 1]) && (i < n - 1 || b[i] != ans[0]))
                    ans[i] = b[i];
                else
                    ans[i] = c[i];
            }
            for (int x: ans)
                System.out.print(x + " ");
            System.out.println();
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rohan Gandhi
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        ACircleColoring solver = new ACircleColoring();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class ACircleColoring {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int[] a = new int[n], b = new int[n], c = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = in.nextInt();
            for (int i = 0; i < n; i++)
                b[i] = in.nextInt();
            for (int i = 0; i < n; i++)
                c[i] = in.nextInt();

            int ans[] = new int[n];
            for (int i = 0; i < n; i++) {
                if ((i == 0 || a[i] != ans[i - 1]) && (i == n - 1 || a[i] != a[i + 1] || a[i] != b[i + 1] || a[i] != c[i + 1]))
                    ans[i] = a[i];
                else if ((i == 0 || b[i] != ans[i - 1]) && (i == n - 1 || b[i] != a[i + 1] || b[i] != b[i + 1] || b[i] != c[i + 1]))
                    ans[i] = b[i];
                else
                    ans[i] = c[i];
            }
            for (int x: ans)
                System.out.print(x + " ");
            System.out.println();
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}