// ACM ICPC Vietnam National Second Round D
//
// 题目大意:
//
// X = X + X % 100.给你一个N和K.求K次操作后N的值
//
// 解题思路:
//
// 看到N和K都是1e9这种数.想到肯定会有循环节.然后
// 打表找规律.一开始发现是20一循环.即4的倍数才可以开
// 始循环,然而太年轻,交了无数发,wrong了无数发.后来发现
// 10这类的也是有循环4一循环.欣喜的敲了一发,然后还是wrong
// 这时候,我又想到了00这种特殊的情况,好,又交,又wrong
// 当然50也要特判啊.25啊,75啊都特判.写完之后,我发现自己太
// 年轻了,这样就可以过了.还是自己考虑问题不够周全吧.
// 情况多多,做练习赛的时候并没有做出来.不得不说自己太弱了.
// 继续加油,FIGHTING!!!
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#define For(x,a,b,c) for (int x = a; x <= b; x += c)
#define Ffor(x,a,b,c) for (int x = a; x >= b; x -= c)
#define cls(x,a) memset(x,a,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX_N = 108;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e6;
ll N,K;
int a[108];
int cnt[108];
bool vis[108];
int main(){
// cls(a,0); //打表所用
// cls(cnt,0);
// for (int i = 1 ;i < 100;i ++){
// cls(vis,0);
// int k = 0;
// vis[i] = 1;
// int x = i;
// x = x + x % 100;
// int t = x % 100;
// int c = 1;
// while(!vis[t]){
// vis[t] = 1;
// x = x + x % 100;
// t = x % 100;
// c++;
// }
// a[i] = x;
// cnt[i] = c;
// // if (i % 10 == 5)
// // printf("%d %d %d\n",i,x,c);
// }
//freopen("1.in","r",stdin);
int kase;
scanf("%d",&kase);
for (int i = 1;i <= kase ;i ++){
scanf("%I64d%I64d",&N,&K);
ll ans = N / 100 * 100;
ll res = N % 100;
if (res == 0){
printf("%I64d\n",N);
continue;
}
if ( res == 50){
printf("%I64d\n", N + 50);
continue;
}
if ( res == 25){
if (K >= 1000000){
printf("%I64d\n",ans + 100);
}
continue;
}
if (res == 75){
if (K >= 1000000){
printf("%I64d\n",ans + 200);
}
continue;
}
if (K < 1000000){
for (int j = 1;j <= K;j ++){
res = res + res % 100;
}
printf("%I64d\n",ans + res);
continue;
}
int c = 0;
if ( res % 10 != 0 || res % 10 != 5){
while((res % 100) % 4){
res += res % 100;
c++;
}
K -= c;
res = res + K / 20 * 1000;
K %= 20;
}
else {
while(((res % 100) / 10) % 2){
res += res % 100;
c++;
}
K -= c;
res = res + K / 4 * 200;
K %= 4;
}
for (int j = 0 ; j < K; j++){
res += res % 100;
}
printf("%I64d\n",ans + res);
}
}