description: In Berland, n different types of banknotes are used. Banknotes of the i-th type have denomination 10^{a_i} burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly 1.
  
  Let's denote f(s) as the minimum number of banknotes required to represent exactly s burles. For example, if the denominations of banknotes used in Berland are 1, 10 and 100, then f(59) = 14: 9 banknotes with denomination of 1 burle and 5 banknotes with denomination of 10 burles can be used to represent exactly 9 ⋅ 1 + 5 ⋅ 10 = 59 burles, and there's no way to do it with fewer banknotes.
  
  For a given integer k, find the minimum positive number of burles s that cannot be represented with k or fewer banknotes (that is, f(s) > k).
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 10^4) — number of test cases.
  
  The first line of each test case contains two integers n and k (1 ≤ n ≤ 10; 1 ≤ k ≤ 10^9).
  
  The next line contains n integers a_1, a_2, ..., a_n (0 = a_1 < a_2 < ... < a_n ≤ 9).
  
  Output
  
  For each test case, print one integer — the minimum positive number of burles s that cannot be represented with k or fewer banknotes.
  
  Example
  
  Input
  
  
  4
  3 13
  0 1 2
  2 777
  0 4
  3 255
  0 1 3
  10 1000000000
  0 1 2 3 4 5 6 7 8 9
  
  
  Output
  
  
  59
  778
  148999
  999999920999999999
solution: /*Everything is Hard 
   * Before Easy 
   * Jai Mata Dii 
   */ 
   
  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; }} 
  	static long mod = (long)(1e9+7); 
  //	 static long mod = 998244353; 
  //	 static Scanner sc = new Scanner(System.in); 
  	static FastReader sc = new FastReader(); 
  	static PrintWriter out = new PrintWriter(System.out);
  	public static void main (String[] args) { 
  		int ttt = 1;
  		ttt = sc.nextInt();
  		z :for(int tc=1;tc<=ttt;tc++){
  			int n = sc.nextInt();
  			long k = sc.nextLong();
  			HashSet<Integer> hs = new HashSet<>();
  			int a[] = new int[n];
  			for(int i=0;i<n;i++) {
  				a[i] = sc.nextInt();
  				hs.add(a[i]);
  			}
  			String cur = "9";
  			long req = 0;
  			while(Long.parseLong(cur)<(long)(9e18)) {
  				int sn = cur.length();
  				long is = 0;
  				long ten = 1;
  				for(int i=0;i<sn;i++) {
  					if(hs.contains(i)) {
  						is = is + (cur.charAt(i)-'0');
  					}
  					else {
  						int cis = 0;
  						for(int j=0;j<n;j++) {
  							if(a[j]>i) break;
  							cis = j;
  						}
  						is = is + (long)(1L*(cur.charAt(i)-'0')*(ten/(long)(Math.pow(10, a[cis]))));
  					}
  					ten = ten*10;
  				}
  				if(is>k) {
  					req = is;
  					break;
  				}
  				cur = cur+"9";
  			}
  //			System.out.println(req);
  			long ans = Long.parseLong(cur);
  			long ten = 1;
  			for(int i=1;i<cur.length();i++) {
  				ten = ten*10;
  			}
  			int curAns[] = new int[cur.length()];
  			for(int i=0;i<cur.length();i++) {
  				curAns[i] = (int)(cur.charAt(i)-'0');
  			}
  			int sn = cur.length();
  			xyz : for(int i=sn-1;i>=0;i--) {
  				int curN = cur.charAt(i)-'0';
  				while(curN>0) {
  //					System.out.println(i+" "+curN);
  					int cis = 0;
  					for(int j=0;j<n;j++) {
  						if(a[j]>i) break;
  						cis = j;
  					}
  					long div = 1;
  					for(int z=1;z<=a[cis];z++) {
  						div = div*10L;
  					}
  					long right = (long) (1L*curN*(ten/div)); 
  					long left = (long) (1L*(curN-1)*(ten/div));
  					if(req-(right-left)>k) {
  						req -= (right-left);
  						curAns[i] = (curN-1);
  //						System.out.println(i+" "+(curN-1));
  					}
  					else {
  						ten/=10L;
  						continue xyz;
  					}
  					curN--;
  				}
  				ten/=10L;
  			}
  			for(int i=curAns.length-1;i>=0;i--) {
  //				if(Character.isDigit(curAns[i])) {
  					out.write(curAns[i]+"");
  //				}
  			}
  			out.write("\n");
  		}
  		out.close();
  	}
  	static long pow(long a, long b){long ret = 1;while(b>0){if(b%2 == 0){a = (a*a)%mod;b /= 2;}else{ret = (ret*a)%mod;b--;}}return ret%mod;}
  	static long gcd(long a,long b){if(b==0) return  a; return gcd(b,a%b); } 
  	private static void sort(int[] a) {List<Integer> k = new ArrayList<>();for(int val : a) k.add(val);Collections.sort(k);for(int i=0;i<a.length;i++) a[i] = k.get(i);} 
  	private static void ini(List<Integer>[] tre2){for(int i=0;i<tre2.length;i++){tre2[i] = new ArrayList<>();}} 
  	private static void init(List<int[]>[] tre2){for(int i=0;i<tre2.length;i++){tre2[i] = new ArrayList<>();}} 
  	private static void sort(long[] a) {List<Long> k = new ArrayList<>();for(long val : a) k.add(val);Collections.sort(k);for(int i=0;i<a.length;i++) a[i] = k.get(i);} 
  }