t=int(input())
while t:
t-=1
n,m=map(int,input().split())
ans=n
k=1
while n>0 and n%10==0:
n//=10
while n>0 and n%5==0:
n//=5
if k*2<=m:
k*=2
else:
break
while n>0 and n%2==0:
n//=2
if k*5<=m:
k*=5
else:
break
while k*10<=m:
k*=10
k=(m//k)*k
print(ans*k)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
void Goal() {
long long n, m;
cin >> n >> m;
long long n2 = n, k = 1;;
while(n % 10 == 0) {
n /= 10;
}
while(n % 2 == 0) {
n /= 2;
if((k * 5) <= m) k = k * 5;
else break;
}
while(n % 5 == 0) {
n = n / 5;
if((k * 2 <= m)) k = k * 2;
else break;
}
while((k * 10) <= m) {
k *= 10;
}
k = (m / k) * k;
long long ans = n2 * k;
cout << ans << '\n';
}
int32_t main() {
fastIO;
#ifndef ONLINE_JUDGE
fileIO;
#endif
int t;
cin >> t;
while(t--) {
Goal();
}
return 0;
}
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |