import java.util.Scanner;

public class Problem1355a {

	private static Scanner sc;

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		sc = new Scanner(System.in);

		int t = sc.nextInt();

		while(t-- > 0)
		{
			long n = sc.nextLong();
			long k = sc.nextLong();

			long ans = solvee(n, k);

			System.out.println(ans);
		}
	}

	private static long solve(long n, long k)
	{
		while(--k > 0)
		{
			long y = multi(n);
			if(y == 0)	break;

			n += y;
		}

		return n;
	}

	private static long multi(long x)
	{
		long max = 9, min = 0;

		while(x > 0)
		{
			long y =  x % 10;
			x = x / 10;
			max = Math.min(max, y);
			min = Math.max(min, y);
		}

		return (max * min);
	}

	private static long solvee(long n, long k)
	{
		if(k == 1)
			return n;

			int max = 9;
			int min = 0;
			long x = n;

			while(x > 0)
			{
				int c = (int) x % 10;

				max = Math.min(max, c);
				min = Math.max(min, c);
				x = x / 10;
			}

			long cal = n + max * min;

			//System.out.println(max + " " + min + " " + cal);

			return (solve(cal,--k));
	}
}


import java.util.Scanner;

public class Problem1355a {

	private static Scanner sc;

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		sc = new Scanner(System.in);

		int t = sc.nextInt();

		while(t-- > 0)
		{
			long n = sc.nextLong();
			long k = sc.nextLong();

			long ans = solvee(n, k);

			System.out.println(ans);
		}
	}

	private static long solve(long n, long k)
	{
		while(--k > 0)
		{
			long y = multi(n);
			if(y == 0)	break;

			n += y;
		}

		return n;
	}

	private static long multi(long x)
	{
		long max = 9, min = 0;

		while(x > 0)
		{
			long y =  x % 10;
			x = x / 10;
			max = Math.min(max, y);
			min = Math.max(min, y);
		}

		return (max * min);
	}

	private static long solvee(long n, long k)
	{
		if(k == 1)
			return n;

			long max = 9;
			long min = 0;
			long x = n;

			while(x > 0)
			{
				long c = x % 10;

				max = Math.min(max, c);
				min = Math.max(min, c);
				x = x / 10;
			}

			long cal = n + max * min;

			//System.out.println(max + " " + min + " " + cal);

			return (solve(cal,--k));
	}
}


import java.util.Scanner;

public class Problem1355a {

	private static Scanner sc;

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		sc = new Scanner(System.in);

		int t = sc.nextInt();

		while(t-- > 0)
		{
			long n = sc.nextLong();
			long k = sc.nextLong();

			long ans = solve(n, k);

			System.out.println(ans);
		}
	}

	private static long solve(long n, long k)
	{
		while(--k > 0)
		{
			int y = multi(n);
			if(y == 0)	break;

			n += y;
		}

		return n;
	}

	private static int multi(long x)
	{
		int max = 10, min = 0;

		while(x > 0)
		{
			int y = (int) x % 10;
			x = x / 10;
			max = Math.min(max, y);
			min = Math.max(min, y);

			if(max * min == 0)
				break;
		}

		return (max * min);
	}
}


import java.io.*;
public class Main
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
    private static int Max(long a)
    {
        int max=Integer.MIN_VALUE;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder>max)
               max=remainder;

            a=a/10;

        }
        return max;
    }

     private static int Min(long a)
    {
        int min=Integer.MAX_VALUE;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder<min)
               min=remainder;

            a=a/10;
        }
        return min;
    }

    public static void main(String [] args) throws java.lang.Exception
    {
      FastReader fr=new FastReader();
      int testcases=fr.nextInt();

      while(testcases>0)
      {
         long a=fr.nextLong();
         long k=fr.nextLong();

         while(k>1)
         {
             int max=Max(a);
             int min=Min(a);
             a=a+max*min;

             k--;

         }

         System.out.println(a);

          testcases--;
      }

    }

}


import java.io.*;
import java.util.*;
public class Main
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
    private static int Max(long a)
    {
        int max=0;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder>max)
               max=remainder;

            a=a/10;

        }
        return max;
    }

     private static int Min(long a)
    {
        int min=9;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder<min)
               min=remainder;

            a=a/10;
        }
        return min;
    }

    public static void main(String [] args) throws java.lang.Exception
    {
      FastReader fr=new FastReader();
      int testcases=fr.nextInt();

      while(testcases>0)
      {
         long a=fr.nextLong();
         long k=fr.nextLong();

         while(k>1)
         {
             int max=Max(a);
             int min=Min(a);
             a=a+max*min;

             k--;

         }

         System.out.println(a);

          testcases--;
      }

    }

}


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

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String [] args) throws java.lang.Exception
    {
        FastReader fr=new FastReader();
        int testcases=fr.nextInt();
        while(testcases>0)
        {
           long a=fr.nextLong();
           long k=fr.nextLong();
           long [] series=new long[(int)k];
           series[0]=a;
           for(long i=1;i<k;i++)
           {
              long s=series[i-1];
              long min=Long.MAX_VALUE;
              long max=Long.MIN_VALUE;

              while(s>0)
               {
                   long remainder=s%10;

                   if(remainder>max)
                     max=remainder;

                    if(remainder<min)
                       min=remainder;

                   s=s/10;
               }

               series[i]=series[i-1]+max*min;

           }
            System.out.println(series[k-1]);
            testcases--;
        }

    }

}


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

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String [] args) throws java.lang.Exception
    {
        FastReader fr=new FastReader();
        int testcases=fr.nextInt();
        while(testcases>0)
        {
           long a=fr.nextLong();
           long k=fr.nextLong();
           long [] series=new long[(int)k];
           series[0]=a;
           for(int i=1;i<k;i++)
           {
              long s=series[i-1];
              long min=Long.MAX_VALUE;
              long max=Long.MIN_VALUE;

              while(s>0)
               {
                   long remainder=s%10;

                   if(remainder>max)
                     max=remainder;

                    if(remainder<min)
                       min=remainder;

                   s=s/10;
               }

               series[i]=series[i-1]+max*min;

           }
            System.out.println(series[k-1]);
            testcases--;
        }

    }

}


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

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String [] args) throws java.lang.Exception
    {
        FastReader fr=new FastReader();
        int testcases=fr.nextInt();
        while(testcases>0)
        {
           long a=fr.nextLong();
           int k=fr.nextInt();
           long [] series=new long[k];
           series[0]=a;
           for(int i=1;i<k;i++)
           {
              long s=series[i-1];
              long min=643786789;
              long max=-744927789;

              while(s>0)
               {
                   long remainder=s%10;

                   if(remainder>max)
                     max=remainder;

                    if(remainder<min)
                       min=remainder;

                   s=s/10;
               }

               series[i]=series[i-1]+max*min;

           }
            System.out.println(series[k-1]);
            testcases--;
        }

    }

}


import java.io.*;
import java.util.*;
public class Main
{
   static class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}
    private static int Max(long a)
    {
        int max=0;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder>max)
               max=remainder;

            a=a/10;

        }
        return max;
    }

     private static int Min(long a)
    {
        int min=9;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder<min)
               min=remainder;

            a=a/10;
        }
        return min;
    }

    public static void main(String [] args) throws java.lang.Exception
    {
      FastReader fr=new FastReader(System.in);
      int testcases=fr.nextInt();

      while(testcases>0)
      {
         long a=fr.nextLong();
         long k=fr.nextLong();

     alaska: while(k>1)
         {
             int max=Max(a);
             int min=Min(a);

             if(min==0)
             break alaska;

             a=a+max*min;

             k--;

         }

         System.out.println(a);

          testcases--;
      }

    }

}


import java.io.*;
import java.util.*;
public class Main
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
    private static int Max(long a)
    {
        int max=0;
      while(a>0)
        {
           int remainder=(int)a%10;
            max=Math.max(remainder,max);

            a=a/10;

        }
        return max;
    }

     private static int Min(long a)
    {
        int min=9;
      while(a>0)
        {
           int remainder=(int)a%10;
          min=Math.min(remainder,min);

            a=a/10;
        }
        return min;
    }

    public static void main(String [] args) throws java.lang.Exception
    {
      FastReader fr=new FastReader();
      int testcases=fr.nextInt();

      while(testcases>0)
      {
         long a=fr.nextLong();
         long k=fr.nextLong();

         while(k>1)
         {
             int max=Max(a);
             int min=Min(a);
             a=a+max*min;

             k--;

         }

         System.out.println(a);

          testcases--;
      }

    }

}


import java.io.*;
import java.util.*;
public class Main
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
    private static int Max(long a)
    {
        int max=0;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder>max)
               max=remainder;

            a=a/10;

        }
        return max;
    }

     private static int Min(long a)
    {
        int min=9;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder<min)
               min=remainder;

            a=a/10;
        }
        return min;
    }

    public static void main(String [] args) throws java.lang.Exception
    {
      FastReader fr=new FastReader();
      int testcases=fr.nextInt();

      while(testcases>0)
      {
         long a=fr.nextLong();
         long k=fr.nextLong();

     alaska: while(k>1)
         {
             int max=Max(a);
             int min=Min(a);

             if(min==0)
             break alaska;

             a=a+max*min;

             k--;

         }

         System.out.println(a);

          testcases--;
      }

    }

}


import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Solution {
    static int getmax(long n){
        int max=0;
        while(n!=0){
            int r=(int)(n%10);
            max=Math.max(r,max);
            n=n/10;
        }
        return max;
    }
    static int getmin(long n){
        int max=9;
        while(n!=0){
            int r=(int)(n%10);
            max=Math.min(r,max);
            n=n/10;
        }
        return max;
    }
    public static void main(String args[]) throws IOException {
        FastReader in = new FastReader(System.in);
        StringBuilder sb = new StringBuilder();
        int i, j;
        int t=in.nextInt();
        while(t-->0){
            long n=in.nextLong();
            long k=in.nextLong();
            while(k-->1){
                int a=getmax(n);
                int b=getmin(n);
                if(b==0)
                    break;
                n=n+a*b;
            }
            sb.append(n).append("\n");
        }

        System.out.print(sb);

    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
    private static int Max(long a)
    {
        int max=0;
      while(a>0)
        {
           int remainder=(int)a%10;
            max=Math.max(remainder,max);

            a=a/10;

        }
        return max;
    }

     private static int Min(long a)
    {
        int min=9;
      while(a>0)
        {
           int remainder=(int)a%10;
          min=Math.min(remainder,min);

            a=a/10;
        }
        return min;
    }

    public static void main(String [] args) throws java.lang.Exception
    {
      FastReader fr=new FastReader();
      int testcases=fr.nextInt();

      while(testcases>0)
      {
         long a=fr.nextLong();
         long k=fr.nextLong();

         while(k>1)
         {
             int max=Max(a);
             int min=Min(a);
             a=a+max*min;

             k--;

         }

         System.out.println(a);

          testcases--;
      }

    }

}


public class Main
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
    private static int Max(int a)
    {
        int max=Integer.MIN_VALUE;
      while(a>0)
        {
           int remiander=a%10;
            if(remainder>max)
               max=remainder;

            a=a/10;

        }
        return max;
    }

         private static int Min(int a)
    {
        int min=Integer.MAX_VALUE;
      while(a>0)
        {
           int remiander=a%10;
            if(remainder<min)
               min=remainder;

            a=a/10;
        }
        return min;
    }

    public static void main(String [] args) throws java.lang.Exception
    {
      FastReader fr=new FastReader();
      int testcases=fr.nextInt();

      while(testcases>0)
      {
         long a=fr.nextLong();
         long k=fr.nextLong();

         while(k>1)
         {
             int max=Max(a);
             int min=Min(a);
             a=a+max*min;

             k--;

         }

         System.out.println(a);

          testcases--;
      }

    }

}


import java.io.*;
import java.util.*;
public class Main
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
    private static int Max(long a)
    {
        int max=Integer.MIN_VALUE;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder>max)
               max=remainder;

            a=a/10;

        }
        return max;
    }

     private static int Min(long a)
    {
        int min=Integer.MAX_VALUE;
      while(a>0)
        {
           int remainder=(int)a%10;
            if(remainder<min)
               min=remainder;

            a=a/10;
        }
        return min;
    }

    public static void main(String [] args) throws java.lang.Exception
    {
      FastReader fr=new FastReader();
      int testcases=fr.nextInt();

      while(testcases>0)
      {
         long a=fr.nextLong();
         long k=fr.nextLong();

         while(k>1)
         {
             int max=Max(a);
             int min=Min(a);
             a=a+max*min;

             k--;

         }

         System.out.println(a);

          testcases--;
      }

    }

}


import java.io.*;
public class Main
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
    private static int Max(int a)
    {
        int max=Integer.MIN_VALUE;
      while(a>0)
        {
           int remiander=a%10;
            if(remainder>max)
               max=remainder;

            a=a/10;

        }
        return max;
    }

         private static int Min(int a)
    {
        int min=Integer.MAX_VALUE;
      while(a>0)
        {
           int remiander=a%10;
            if(remainder<min)
               min=remainder;

            a=a/10;
        }
        return min;
    }

    public static void main(String [] args) throws java.lang.Exception
    {
      FastReader fr=new FastReader();
      int testcases=fr.nextInt();

      while(testcases>0)
      {
         long a=fr.nextLong();
         long k=fr.nextLong();

         while(k>1)
         {
             int max=Max(a);
             int min=Min(a);
             a=a+max*min;

             k--;

         }

         System.out.println(a);

          testcases--;
      }

    }

}


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

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String [] args) throws java.lang.Exception
    {
        FastReader fr=new FastReader();
        int testcases=fr.nextInt();
        while(testcases>0)
        {
           int a=fr.nextInt();
           int k=fr.nextInt();
           int [] series=new int[k];
           series[0]=a;
           for(int i=1;i<k;i++)
           {
              int s=series[i-1];
              int min=Integer.MAX_VALUE;
              int max=Integer.MIN_VALUE;

              while(s>0)
               {
                   int remainder=s%10;

                   if(remainder>max)
                     max=remainder;

                    if(remainder<min)
                       min=remainder;

                   s=s/10;
               }

               series[i]=series[i-1]+max*min;

           }
            System.out.println(series[k-1]);
            testcases--;
        }

    }

}


import java.io.*;
import java.util.*;
import java.lang.*;
public class x{
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new
                    InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
     }
public static long call(long a, long k){
    if(k==0){
         return a;
    }
    long a1=a;
    long min=Long.MAX_VALUE;
    long max=0;
    while(a1>0){
         long d = a1%10;
         if(min==0){
              return a;
         }
         if(d>max){
              max = d;
         }
         if(d<min){
              min = d;
         }
         a1=a1/10;
    }
    return call(a+min*max,k-1);
}
public static void main(String args[]){
    try{
         FastScanner sc=new FastScanner(System.in);
         int t=sc.nextInt();
         while(t-->0){
              long n=sc.nextLong();
              long k=sc.nextLong();
              System.out.println(call(n,k-1));
         }
    }catch(Exception e){}
}
}


import java.util.*;
import java.io.*;
public class A{
     static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new
                    InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
     }
     // static class Pair{
     //      int l,r;
     //      Pair(int l,int r){
     //           this.l=l;
     //           this.r=r;
     //      }
     // }
     // static class My_Comparator implements Comparator<Pair>{
     //      public int compare(Pair p1,Pair p2){
     //           //return 1 if p1>p2, 0 if they are equal, or -1 if p1<p2
     //           return 0;
     //      }
     // }
     // long minstep = Long.MAX_VALUE;
     public static long call(long a, long k){
          if(k==0){
               return a;
          }
          long a1=a;
          long min=9;
          long max=0;
          while(a1>0){
               int d = (int)(a1%10);
               if(min==0){
                    return a;
               }
               if(d>max){
                    max = d;
               }
               if(d<min){
                    min = d;
               }
               a1=a1/10;
          }
          return call(a+min*max,k-1);
     }
     public static void main(String args[]){
          try{
               FastScanner sc=new FastScanner(System.in);
               int t=sc.nextInt();
               while(t-->0){
                    long n=sc.nextLong();
                    long k=sc.nextLong();
                    System.out.print(call(n,k-1));
               }
          }catch(Exception e){}
     }
}


import java.util.*;
import java.io.*;
public class A{
     static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new
                    InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
     }
     // static class Pair{
     //      int l,r;
     //      Pair(int l,int r){
     //           this.l=l;
     //           this.r=r;
     //      }
     // }
     // static class My_Comparator implements Comparator<Pair>{
     //      public int compare(Pair p1,Pair p2){
     //           //return 1 if p1>p2, 0 if they are equal, or -1 if p1<p2
     //           return 0;
     //      }
     // }
     // long minstep = Long.MAX_VALUE;
     public static long call(long a, long k){
          if(k==0){
               return a;
          }
          long a1=a;
          long min=Long.MAX_VALUE;
          long max=0;
          while(a1>0){
               long d = a1%10;
               if(min==0){
                    return a;
               }
               if(d>max){
                    max = d;
               }
               if(d<min){
                    min = d;
               }
               a1=a1/10;
          }
          return call(a+min*max,k-1);
     }
     public static void main(String args[]){
          try{
               FastScanner sc=new FastScanner(System.in);
               int t=sc.nextInt();
               while(t-->0){
                    long n=sc.nextLong();
                    long k=sc.nextLong();
                    System.out.print(call(n,k-1));
               }
          }catch(Exception e){}
     }
}


import java.io.*;
import java.util.*;
import java.lang.*;
public class A{
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new
                    InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
     }
public static long call(long a, long k){
    if(k==0){
         return a;
    }
    long a1=a;
    long min=Long.MAX_VALUE;
    long max=0;
    while(a1>0){
         int d = (int)(a1%10);
         if(min==0){
              return a;
         }
         if(d>max){
              max = d;
         }
         if(d<min){
              min = d;
         }
         a1=a1/10;
    }
    return call(a+min*max,k-1);
}
public static void main(String args[]){
    try{
         FastScanner sc=new FastScanner(System.in);
         int t=sc.nextInt();
         while(t-->0){
              long n=sc.nextLong();
              long k=sc.nextLong();
              System.out.println(call(n,k-1));
         }
    }catch(Exception e){}
}
}


import java.util.*;
import java.io.*;
public class A{
     static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new
                    InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
     }
     // static class Pair{
     //      int l,r;
     //      Pair(int l,int r){
     //           this.l=l;
     //           this.r=r;
     //      }
     // }
     // static class My_Comparator implements Comparator<Pair>{
     //      public int compare(Pair p1,Pair p2){
     //           //return 1 if p1>p2, 0 if they are equal, or -1 if p1<p2
     //           return 0;
     //      }
     // }
     // long minstep = Long.MAX_VALUE;
     public static long call(long a, long k){
          if(k==0){
               return a;
          }
          long a1=a;
          long min=9;
          long max=0;
          while(a1>0){
               long d = (int)(a1%10);
               if(min==0){
                    return a;
               }
               if(d>max){
                    max = d;
               }
               if(d<min){
                    min = d;
               }
               a1=a1/10;
          }
          return call(a+min*max,k-1);
     }
     public static void main(String args[]){
          try{
               FastScanner sc=new FastScanner(System.in);
               int t=sc.nextInt();
               while(t-->0){
                    long n=sc.nextLong();
                    long k=sc.nextLong();
                    System.out.print(call(n,k-1));
               }
          }catch(Exception e){}
     }
}


import java.util.*;
import java.io.*;
public class A{
     static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new
                    InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
     }
     // static class Pair{
     //      int l,r;
     //      Pair(int l,int r){
     //           this.l=l;
     //           this.r=r;
     //      }
     // }
     // static class My_Comparator implements Comparator<Pair>{
     //      public int compare(Pair p1,Pair p2){
     //           //return 1 if p1>p2, 0 if they are equal, or -1 if p1<p2
     //           return 0;
     //      }
     // }
     // long minstep = Long.MAX_VALUE;
     public static long call(long a, long k){
          if(k==0){
               return a;
          }
          long a1=a;
          long min=Long.MAX_VALUE;
          long max=0;
          while(a1>0){
               int d = (int)a1%10;
               if(min==0 && max==9){
                    break;
               }
               if(d>max){
                    max = d;
               }
               if(d<min){
                    min = d;
               }
               a1=a1/10;
          }
          return call(a+min*max,k-1);
     }
     public static void main(String args[]){
          try{
               FastScanner sc=new FastScanner(System.in);
               int t=sc.nextInt();
               while(t-->0){
                    long n=sc.nextLong();
                    long k=sc.nextLong();
                    System.out.print(call(n,k-1));
               }
          }catch(Exception e){}
     }
}


import java.util.*;

public class Main {
    static long minDigit(long x){
        if (x == 0) return 0;
        long min = 10;
        while (x > 0){
            min = Math.min(x % 10, min);
            x /= 10;
        }
        return min;
    }

    static long maxDigit(long x){
        if (x == 0) return 0;
        long max = -1;
        while (x > 0){
            max = Math.max(x % 10, max);
            x /= 10;
        }
        return max;
    }
    static long f(long x, long k){
        if (k == 1)
            return x;
        if (maxDigit(x) == 0 || minDigit(x) == 0)
            return x;
        return f(x + maxDigit(x)*minDigit(x), k - 1);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int test = sc.nextInt();
        for (int t = 0; t < test; t++) {
            int a = sc.nextInt(), k = sc.nextInt();
            System.out.println(f(a, k));

        }
    }
}


import java.util.*;

public class Main {
    static long minDigit(long x){
        if (x == 0) return 0;
        long min = 10;
        while (x > 0){
            min = Math.min(x % 10, min);
            x /= 10;
        }
        return min;
    }

    static long maxDigit(long x){
        if (x == 0) return 0;
        long max = -1;
        while (x > 0){
            max = Math.max(x % 10, max);
            x /= 10;
        }
        return max;
    }
    static long f(long x, long k){
        if (k == 1)
            return x;
        if (maxDigit(x) == 0 || minDigit(x) == 0)
            return x;
        return f(x + maxDigit(x)*minDigit(x), k - 1);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int test = sc.nextInt();
        for (int t = 0; t < test; t++) {
            long a = sc.nextLong(), k = sc.nextLong();
            System.out.println(f(a, k));

        }
    }
}


import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Locale;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int testCase = scanner.nextInt();
        for(int testRunning = 1; testRunning <= testCase; testRunning++){
            long a = scanner.nextInt();
            long k = scanner.nextInt();

            for(int i = 1; i < k; i++){
                String integerString = String.valueOf(a);
                char[] characterArray = integerString.toCharArray();
                Arrays.sort(characterArray);
                int maxDigit = Character.getNumericValue(characterArray[0]);
                int minDigit = Character.getNumericValue(characterArray[characterArray.length-1]);
                if(maxDigit == 0 || minDigit == 0){
                    break;
                }
                else{
                    a = a + maxDigit * minDigit;
                }
            }
            System.out.println(a);
        }
    }
}


import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Locale;
import java.util.Scanner;

public class Main {
    //new declaration
    //shortcut declaration
    //concatenation
    //length
    //toLowerCase(), toUpperCase()
    //startsWith(), endsWith()
    //indexOf()
    //trim()
    //replace()
    //immutablity()
    //Hello \"arfin"
    //c:\\Windows\...
    //\n \t

    //Arrays
    //Variable to array
    //Exception Peak
    //Printing array Address
    //Arrays Class to print
    //Curly Braces declaration
    //Array Lenght
    //Array Sort
    //deepToString()
    //int[][] ara = {{1,2,3}, {4,5,6}};
    //System.out.println(Arrays.deepToString(ara));
    public static void main(String[] args) {
//        int[][] ara = {{1,2,3}, {4,5,6}};
//        System.out.println(Arrays.deepToString(ara));
//        final int PI = 3;
//        double val = 5.0 / 2;
//        System.out.println(val);
//        int x = 1;
//        x++;
//        ++x;
//        int y = ++x;
//        System.out.println(y);
//        System.out.println(x);

//        int m = (10 + 3) * 3; // (), */, +-
//        System.out.println(m);

        //*Casting
        //Implicit Casting - Automatic Conversion
        //byte > short > int > long > float > double
        //Explicit Casting (int)
        //Only compatble types
//        String x = "2"; // 2 byte
//        double z = Double.parseDouble(x) + 4; // 4 byte
//        System.out.println(z);
//
//        //==The math class
//        Math.max(1, 2);
//        Math.min(1, 2);
//        Math.round(2.3F);
//        Math.ceil(2.3F);
//        Math.random();
//        long randNum = Math.round(Math.random() * 100);
//
//        //==Formating Numbers
//        //$123,456,789
//        //0.1% -> 10%
//        System.out.println(NumberFormat.getInstance());

        Scanner scanner = new Scanner(System.in);
        int testCase = scanner.nextInt();
        for(int testRunning = 1; testRunning <= testCase; testRunning++){
            long a = scanner.nextLong();
            long k = scanner.nextLong();

            for(int i = 1; i < k; i++){
                String integerString = String.valueOf(a);
                char[] characterArray = integerString.toCharArray();
                Arrays.sort(characterArray);
                int maxDigit = Character.getNumericValue(characterArray[0]);
                int minDigit = Character.getNumericValue(characterArray[characterArray.length-1]);
                if(maxDigit == 0 || minDigit == 0){
                    break;
                }
                else{
                    a = a + maxDigit * minDigit;
                }
            }
            System.out.println(a);
        }

    }
}


package com.company;

import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Locale;
import java.util.Scanner;

public class Main {
    //new declaration
    //shortcut declaration
    //concatenation
    //length
    //toLowerCase(), toUpperCase()
    //startsWith(), endsWith()
    //indexOf()
    //trim()
    //replace()
    //immutablity()
    //Hello \"arfin"
    //c:\\Windows\...
    //\n \t

    //Arrays
    //Variable to array
    //Exception Peak
    //Printing array Address
    //Arrays Class to print
    //Curly Braces declaration
    //Array Lenght
    //Array Sort
    //deepToString()
    //int[][] ara = {{1,2,3}, {4,5,6}};
    //System.out.println(Arrays.deepToString(ara));
    public static void main(String[] args) {
//        int[][] ara = {{1,2,3}, {4,5,6}};
//        System.out.println(Arrays.deepToString(ara));
//        final int PI = 3;
//        double val = 5.0 / 2;
//        System.out.println(val);
//        int x = 1;
//        x++;
//        ++x;
//        int y = ++x;
//        System.out.println(y);
//        System.out.println(x);

//        int m = (10 + 3) * 3; // (), */, +-
//        System.out.println(m);

        //*Casting
        //Implicit Casting - Automatic Conversion
        //byte > short > int > long > float > double
        //Explicit Casting (int)
        //Only compatble types
//        String x = "2"; // 2 byte
//        double z = Double.parseDouble(x) + 4; // 4 byte
//        System.out.println(z);
//
//        //==The math class
//        Math.max(1, 2);
//        Math.min(1, 2);
//        Math.round(2.3F);
//        Math.ceil(2.3F);
//        Math.random();
//        long randNum = Math.round(Math.random() * 100);
//
//        //==Formating Numbers
//        //$123,456,789
//        //0.1% -> 10%
//        System.out.println(NumberFormat.getInstance());

        Scanner scanner = new Scanner(System.in);
        int testCase = scanner.nextInt();
        for(int testRunning = 1; testRunning <= testCase; testRunning++){
            long a = scanner.nextLong();
            long k = scanner.nextLong();

            for(int i = 1; i < k; i++){
                String integerString = String.valueOf(a);
                char[] characterArray = integerString.toCharArray();
                Arrays.sort(characterArray);
                int maxDigit = Character.getNumericValue(characterArray[0]);
                int minDigit = Character.getNumericValue(characterArray[characterArray.length-1]);
                if(maxDigit == 0 || minDigit == 0){
                    break;
                }
                else{
                    a = a + maxDigit * minDigit;
                }
            }
            System.out.println(a);
        }

    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class main {
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    class Implementations {

    }

    public static void main(String[] args) throws IOException {
        Reader s = new Reader();
        int T = s.nextInt();
        while (T-- != 0) {
            long a = s.nextLong();
            long k = s.nextLong();
            System.out.println(new solve().solve(Long.toString(a), k));
        }
    }

    static class solve {
        public String solve(String a, long k) {
            String res = a;
            for (int i=2; i<=k; i++) {
                ArrayList<Character> li = new ArrayList<>();
                for (int j=0; j<res.length(); j++) {
                    li.add(res.charAt(j));
                }
                res = Long.toString(Long.parseLong(res) + ((Collections.min(li) - '0') * (Collections.max(li) - '0')));
            }
            return res;
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class main {
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    class Implementations {

    }

    public static void main(String[] args) throws IOException {
        Reader s = new Reader();
        int T = s.nextInt();
        while (T-- != 0) {
            long a = s.nextLong();
            long k = s.nextLong();
            System.out.println(new solve().solve(Long.toString(a), k));
        }
    }

    static class solve {
        public String solve(String a, long k) {
            String res = a;
            for (int i=2; i<=k; i++) {
                ArrayList<Character> li = new ArrayList<>();
                for (int j=0; j<a.length(); j++) {
                    li.add(res.charAt(j));
                }
                res = Long.toString(Long.parseLong(res) + ((Collections.min(li) - '0') * (Collections.max(li) - '0')));
            }
            return res;
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class main {
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    class Implementations {

    }

    public static void main(String[] args) throws IOException {
        Reader s = new Reader();
        int T = s.nextInt();
        while (T-- != 0) {
            int a = s.nextInt();
            int k = s.nextInt();
            System.out.println(new solve().solve(Integer.toString(a), k));
        }
    }

    static class solve {
        public String solve(String a, int k) {
            if (k == 1) {
                return a;
            }
            String res = solve(a, k-1);
            ArrayList<Character> li = new ArrayList<>();
            for (int i=0; i<res.length(); i++) {
                li.add(res.charAt(i));
            }
            return Integer.toString(Integer.parseInt(res) + (Collections.min(li) - '0') * (Collections.max(li) - '0'));
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class main {
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    class Implementations {

    }

    public static void main(String[] args) throws IOException {
        Reader s = new Reader();
        int T = s.nextInt();
        while (T-- != 0) {
            long a = s.nextLong();
            long k = s.nextLong();
            System.out.println(new solve().solve(a, k));
        }
    }

    static class solve {
        int min_max_prod(long a) {
            int min = 10, max = -1;
            while (a > 0) {
                int d = (int)(a%10);
                min = Math.min(min, d);
                max = Math.max(max, d);
                a /= 10;
            }
            return (min * max);
        }
        public long solve(long a, long k) {
            while (k-- != 1) {
                int prod = min_max_prod(a);
                if (prod == 0) break;
                a += prod;
            }
            return a;
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class c_1355A{
	static FastReader fr = new FastReader();
	public static void main(String[] args){
		int t = fr.nextInt();
		while(t-- > 0){
            long a = fr.nextLong();
            long k = fr.nextLong();
            while(k-- > 0){
                long y = product(a);
                if(y == 0){
                    break;
                }
                a += y ;
            }
            System.out.println(a);
        }
	}
    public static long product(long x){
        long m1 = 10;
        long m2 = 0 ;
        while(x > 0){
            long y = x%10;
            x = x/10;
            m1 = (long)Math.min(m1, y);
            m2 = (long)Math.max(m2, y);
        }
        return m1*m2 ;
    }
}

class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class c_1355A{
	static FastReader fr = new FastReader();
	public static void main(String[] args){
		int t = fr.nextInt();
		while(t-- > 0){
            long a = fr.nextLong();
            long k = fr.nextLong();
            while(k-- > 0){
                long m1 = 10 ;
                long m2 = 0 ;
                long x = a ;
                while(x > 0){
                    long r = x%10 ;
                    x = x/10;
                    m1 = (long)Math.min(m1, r);
                    m2 = (long)Math.max(m2, r);
                }
                if(m1*m2 == 0){
                    break;
                }
                a = a + m1*m2 ;
            }
            System.out.println(a);
        }
	}
}

class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class c_1355A{
	static FastReader fr = new FastReader();
	public static void main(String[] args){
		int t = fr.nextInt();
		while(t-- > 0){
            long a = fr.nextLong();
            long k = fr.nextLong();
            k--;
            while(k-- > 0){
                long y = product(a);
                if(y == 0){
                    break;
                }
                a += y ;
            }
            System.out.println(a);
        }
	}
    public static long product(long x){
        long m1 = 10;
        long m2 = 0 ;
        while(x > 0){
            long y = x%10;
            x = x/10;
            m1 = (long)Math.min(m1, y);
            m2 = (long)Math.max(m2, y);
        }
        return m1*m2 ;
    }
}

class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.text.NumberFormat;
//import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

public class Main {

    public static boolean isPrime(long n) {
        if (n == 2) {
            return true;
        }
        if (n == 1 || n % 2 == 0) {
            return false;
        }
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) throws IOException {
        InputStreamReader r = new InputStreamReader(System.in);
        BufferedReader input = new BufferedReader(r);
        int t = Integer.parseInt(input.readLine());
        for (int l = 0; l < t; l++) {
            String[] temp = input.readLine().split(" ");
            long a1 = Long.parseLong(temp[0]);
            String a = Long.toString(a1);
            long k = Long.parseLong(temp[1]);
            long max = -1;
            long min = 11;
            for (long j = 1; j < k; j++) {
                if(max==0||min==0){
                    break;
                }
                max = -1;
                min = 11;
                for (int i = 0; i < a.length(); i++) {
                    if (Long.parseLong(Character.toString(a.charAt(i))) > max) {
                        max = Long.parseLong(Character.toString(a.charAt(i)));
                    }
                    if (Long.parseLong(Character.toString(a.charAt(i))) < min) {
                        min = Long.parseLong(Character.toString(a.charAt(i)));
                    }
                }
                a=Long.toString(Long.parseLong(a)+(max*min));
            }
            System.out.println(a);

        }
    }
}


package test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
import java.text.NumberFormat;
//import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

public class Main {

    public static boolean isPrime(long n) {
        if (n == 2) {
            return true;
        }
        if (n == 1 || n % 2 == 0) {
            return false;
        }
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) throws IOException {
        InputStreamReader r = new InputStreamReader(System.in);
        BufferedReader input = new BufferedReader(r);
        int t = Integer.parseInt(input.readLine());
        for (int l = 0; l < t; l++) {
            String[] temp = input.readLine().split(" ");
            long a1 = Long.parseLong(temp[0]);
            String a = Long.toString(a1);
            long k = Long.parseLong(temp[1]);
            long max = -1;
            long min = 11;
            for (long j = 1; j < k; j++) {
                if(max==0||min==0){
                    break;
                }
                max = -1;
                min = 11;
                for (int i = 0; i < a.length(); i++) {
                    if (Long.parseLong(Character.toString(a.charAt(i))) > max) {
                        max = Long.parseLong(Character.toString(a.charAt(i)));
                    }
                    if (Long.parseLong(Character.toString(a.charAt(i))) < min) {
                        min = Long.parseLong(Character.toString(a.charAt(i)));
                    }
                }
                a=Long.toString(Long.parseLong(a)+(max*min));
            }
            System.out.println(a);

        }
    }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            long a1 = sc.nextLong();
            long k = sc.nextLong();
            long res = a1;
            while(k-->1){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
            }

            System.out.println(res);

        }
    }
        public static long min(long n){
            List<Long> l = new ArrayList<Long>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static long max(long n){
            List<Long> l = new ArrayList<Long>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class file{{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
            }
            System.out.println(res);

        }
    }
        public static int min(int n){
            List<<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }

    }


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
                System.out.println(res+", and k is "+k +"and min is "+mi+"and max is "+mx );
            }

        }
    }
        public static int min(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            long a1 = sc.nextLong();
            long k = sc.nextLong();
            long res = a1;
            while(k-->1){
                int mi =(int) min(res);
                int mx = (int)max(res);
                res = res+mi*mx;
            }

            System.out.println(res);

        }
    }
        public static long min(long n){
            int m=100;
            while(n>0){
                int x = n%10;
                int r = Math.min(x,m);
                m=r;
                n = n/10;
            }

        }
        public static long max(long n){
            int m=0;
            while(n>0){
                int x = n%10;
                int r = Math.max(x,m);
                m=r;
                n = n/10;
            }

        }
}


import java.util.*
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int n = sc.nextInt();
            int arr[] = new int[n];

            for(int i=0;i<n;i++){
                arr[i] = sc.nextInt();
            }
            int f=0;
            int m = arr[0];
            for(int i=1;i<n;i++){
                if(arr[i]==m)
                f=1;
                else
                break;
            }
            if(f==1){
                System.out.println(n);
            }
            else
            System.out.println(n/2);

        }
    }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
            }
            System.out.println(res);

        }
    }
        public static int min(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            long a1 = sc.nextLong();
            long k = sc.nextLong();
            long res = a1;
            while(k-->1){
                int mi =(int) min(res);
                int mx = (int)max(res);
                res = res+mi*mx;
            }

            System.out.println(res);

        }
    }
        public static long min(long n){
            int m=100;
            while(n>0){
                long x = n%10;
                long r = Math.min(x,m);
                m=r;
                n = n/10;
            }
            return m;

        }
        public static long max(long n){
            int m=0;
            while(n>0){
                long x = n%10;
                long r = Math.max(x,m);
                m=r;
                n = n/10;
            }
            return m;

        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->1){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
            }

            System.out.println(res);

        }
    }
        public static int min(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int n = sc.nextInt();
            int arr[] = new int[n];

            for(int i=0;i<n;i++){
                arr[i] = sc.nextInt();
            }
            Arrays.sort(arr);
            if(arr[0]==arr[n-1]){
                System.out.println(n);
            }
            else
            System.out.println(n/2);

        }
    }


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            long a1 = sc.nextLong();
            long k = sc.nextLong();
            long res = a1;
            while(k-->1){
                int mi =(int) min(res);
                int mx = (int)max(res);
                res = res+mi*mx;
            }

            System.out.println(res);

        }
    }
        public static long min(long n){
            List<Long> l = new ArrayList<Long>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static long max(long n){
            List<Long> l = new ArrayList<Long>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            long a1 = sc.nextLong();
            long k = sc.nextLong();
            long res = a1;
            while(k-->1){
                int mi =(int) min(res);
                int mx = (int)max(res);
                if(mi*mx==0)
                break;
                res = res+mi*mx;
            }

            System.out.println(res);

        }
    }
        public static long min(long n){
            long m=100;
            while(n>0){
                long x = n%10;
                long r = Math.min(x,m);
                m=r;
                n = n/10;
            }
            return m;

        }
        public static long max(long n){
            long m=0;
            while(n>0){
                long x = n%10;
                long r = Math.max(x,m);
                m=r;
                n = n/10;
            }
            return m;

        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
            }

            System.out.println(res);

        }
    }
        public static int min(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            long a1 = sc.nextLong();
            long k = sc.nextLong();
            long res = a1;
            while(k-->1){
                int mi =(int) min(res);
                int mx = (int)max(res);
                res = res+mi*mx;
            }

            System.out.println(res);

        }
    }
        public static long min(long n){
            long m=100;
            while(n>0){
                long x = n%10;
                long r = Math.min(x,m);
                m=r;
                n = n/10;
            }
            return m;

        }
        public static long max(long n){
            long m=0;
            while(n>0){
                long x = n%10;
                long r = Math.max(x,m);
                m=r;
                n = n/10;
            }
            return m;

        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
            }
            System.out.println(res);

        }
    }
        public static int min(int n){
            List<<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }

    }


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
                System.out.println(res+","+t);
            }

        }
    }
        public static int min(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
                System.out.println(res+", and k is "+k +"and min is "+mi+"and max is "+mx );
            }

        }
    }
        public static int min(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class java{{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
            }

        }

    }

}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
            }
            System.out.println(res);

        }
    }
        public static int min(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            long a1 = sc.nextLong();
            long k = sc.nextLong();
            long res = a1;
            while(k-->1){
                int mi =(int) min(res);

                res = res+mi;
            }

            System.out.println(res);

        }
    }
        public static long min(long n){
            long m1=10,m2=0;
            while(n>0){
                long x = n%10;
                long r = Math.min(x,m1);
                long r1 = Math.max(x,m2);
                m1=r;
                m2=r1;
                n = n/10;
            }
            return m1*m2;

        }

}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int a1 = sc.nextInt();
            int k = sc.nextInt();
            int res = a1;
            while(k-->0){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
                System.out.println(res+", and k is "+k +"and min is "+mi+"and max is "+mx );
            }

        }
    }
        public static int min(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(int n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n/10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            long a1 = sc.nextLong();
            long k = sc.nextLong();
            long res = a1;
            while(k-->1){
                int mi = min(res);
                int mx = max(res);
                res = res+mi*mx;
            }

            System.out.println(res);

        }
    }
        public static int min(long n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(0);
        }
        public static int max(long n){
            List<Integer> l = new ArrayList<Integer>();
            while(n>0){
                l.add(n%10);
                n = n/10;
            }
            Collections.sort(l);
            return l.get(l.size()-1);
        }
}


import java.util.*;
public class file{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            long a1 = sc.nextLong();
            long k = sc.nextLong();
            long res = a1;
            while(k-->1){
                int mi =(int) min(res);
                if(mi==0)
                break;
                res = res+mi;
            }

            System.out.println(res);

        }
    }
        public static long min(long n){
            long m1=10,m2=0;
            while(n>0){
                long x = n%10;
                long r = Math.min(x,m1);
                long r1 = Math.max(x,m2);
                m1=r;
                m2=r1;
                n = n/10;
            }
            return m1*m2;

        }

}