def deci(y):
L=[]
for i in range(len(y)):
L.append(int(y[i]))
return L
for _ in range(int(input())):
n,k=map(int,input().split())
for i in range(k-1):
if 0 in deci(str(n)):
break
n=n+(min(deci(str(n)))*max(deci(str(n))))
print(n)
/*
Author: Atul chandra
*/
#include<bits/stdc++.h>
using namespace std;
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rloop(i,a,b) for(long long i=a;i>=b;i--)
#define ll long long
#define mp make_pair
#define pb push_back
#define vll vector<long long>
#define vvl vector<vll>
#define pll pair<ll,ll>
#define vc vector
#define ff first
#define ss second
#define lb lower_bound
#define POW(a,b) (ll)(pow(a,b)+0.5)
#define gcd __gcd
#define remove_unique(x) x.erase(unique(x.begin(),x.end()),x.end())
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define p_q priority_queue
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define all(x) x.begin(),x.end()
#define inc(x,start) iota(x.begin(),x.end(),start)
#define pi 3.141592653589793238
#define inf LONG_LONG_MAX
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define ios ios_base::sync_with_stdio(0)
#define tie cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
// long long Ceil(long long a,long long b){return (a+b-1)/b;}
// long long Sqrt(long long x){ long long y=sqrt(x)+5;while(y*y>x)y--;return y;}
template <class T> void _print(T t){ cerr << t;}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
//--------------------------------------------------------------------------------------------------------------------------------------//
/* Atul chandra */
//--------------------------------------------------------------------------------------------------------------------------------------//
const int mod = 1e9 + 7;
void helper(){
ll a,k;
cin>>a>>k;
k--;
while(k>0){
ll m = a;
int mini = 10;
int maxi = 0;
while(m>0){
int d = m%10;
mini = min(mini, d);
maxi = max(maxi, d);
m/=10;
}
if(mini == 0) break;
a += (mini*maxi);
k--;
}
cout<<a<<endl;
}
int main(){
ios;tie;
int T;
cin>>T;
while(T--){
helper();
}
return 0;
}
810A - Straight A | 1433C - Dominant Piranha |
633A - Ebony and Ivory | 1196A - Three Piles of Candies |
299A - Ksusha and Array | 448B - Suffix Structures |
1092B - Teams Forming | 1166C - A Tale of Two Lands |
544B - Sea and Islands | 152B - Steps |
1174D - Ehab and the Expected XOR Problem | 1511A - Review Site |
1316A - Grade Allocation | 838A - Binary Blocks |
1515D - Phoenix and Socks | 1624D - Palindromes Coloring |
1552F - Telepanting | 1692G - 2Sort |
1191A - Tokitsukaze and Enhancement | 903A - Hungry Student Problem |
52B - Right Triangles | 1712A - Wonderful Permutation |
1712D - Empty Graph | 1712B - Woeful Permutation |
1712C - Sort Zero | 1028B - Unnatural Conditions |
735B - Urbanization | 746C - Tram |
1278B - A and B | 1353D - Constructing the Array |