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: 
  /*
   
  
                                             بسم الله الرحمن الرحيم 
                                        
      /$$$$$  /$$$$$$  /$$    /$$  /$$$$$$                                                                  
     |__  $$ /$$__  $$ |$$    |$$ /$$__  $$                                                                 
            | $$| $$  \ $$|    $$|$$| $$  \ $$                                                                 
            | $$| $$$$$$$$|  $$ / $$/| $$$$$$$$                                                                 
  / $$  | $$| $$__  $$ \  $$ $$/ | $$__  $$                                                                 
  | $$  | $$| $$  | $$  \  $$$/  | $$  | $$                                                                 
  |  $$$$$$/| $$  | $$   \  $/   | $$  | $$                                                                 
   \______/ |__/  |__/    \_/    |__/  |__/    
   
  /$$$$$$$  /$$$$$$$   /$$$$$$   /$$$$$$  /$$$$$$$   /$$$$$$  /$$      /$$ /$$      /$$ /$$$$$$$$ /$$$$$$$ 
  | $$__  $$| $$__  $$ /$$__  $$ /$$__  $$| $$__  $$ /$$__  $$| $$$    /$$$| $$$    /$$$| $$_____/| $$__  $$
  | $$  \ $$| $$  \ $$| $$  \ $$| $$  \__/| $$  \ $$| $$  \ $$| $$$$  /$$$$| $$$$  /$$$$| $$      | $$  \ $$
  | $$$$$$$/| $$$$$$$/| $$  | $$| $$ /$$$$| $$$$$$$/| $$$$$$$$| $$ $$/$$ $$| $$ $$/$$ $$| $$$$$   | $$$$$$$/
  | $$____/ | $$__  $$| $$  | $$| $$|_  $$| $$__  $$| $$__  $$| $$  $$$| $$| $$  $$$| $$| $$__/   | $$__  $$
  | $$      | $$  \ $$| $$  | $$| $$  \ $$| $$  \ $$| $$  | $$| $$\  $ | $$| $$\  $ | $$| $$      | $$  \ $$
  | $$      | $$  | $$|  $$$$$$/|  $$$$$$/| $$  | $$| $$  | $$| $$ \/  | $$| $$ \/  | $$| $$$$$$$$| $$  | $$
  |__/      |__/  |__/ \______/  \______/ |__/  |__/|__/  |__/|__/     |__/|__/     |__/|________/|__/  |__/
                                                                                                                                                                                                                  
                                                                                                                                                                                                                  
   
  */
  
  import java.util.*;
  import java.lang.*;
  import java.io.*;
  
  public class Banknotes {
      public static void main(String[] args) throws java.lang.Exception {
          // your code goes here
          //try {
              // Scanner sc=new Scanner(System.in);
              FastReader sc = new FastReader();
              int t =sc.nextInt();
              long[] powers=new long[10];
              powers[0]=1;
              for(int i=1;i<=9;i++){
                  powers[i]=powers[i-1]*10l;
              }
              
              //long an=pow(10,2);
              //System.out.println(an+" ha ha ha");
              while (t-- > 0) {
                  int n=sc.nextInt();
                  long k=sc.nextLong();
                  long[] arr=new long[n];
                  for(int i=0;i<n;i++){
                      arr[i]=sc.nextLong();
                  }
                 long money=0;
                 for(int i=0;i<n;i++){
                     if(k<0)break;
                     long minnoocc=k+1l;
                     if(i!=n-1){
                         minnoocc=Math.min(minnoocc,(powers[(int)arr[i+1]]/powers[(int)arr[i]])-1);
                     }
                     k-=minnoocc;
                     money+=(minnoocc*powers[(int)arr[i]]);
                 }
                  System.out.println(money);
                  /*int[] arr=new int[n];
                  for(int i=0;i<n;i++){
                      arr[i]=sc.nextInt();
                  }*/
                  /*long[] arr=new long[n];
                  for(int i=0;i<n;i++){
                      arr[i]=sc.nextLong();
                  }*/
              }
          /*} catch (Exception e) {
              return;
          }*/
  
      }
      public static class pair{
          int ff;
          int ss;
          pair(int ff,int ss){
              this.ff=ff;
              this.ss=ss;
          }
      }
      
  
      static int BS(int[] arr, int l, int r, int element) {
          int low = l;
          int high = r;
          while (high - low > 1) {
              int mid = low + (high - low) / 2;
              if (arr[mid] < element) {
                  low = mid + 1;
              } else {
                  high = mid;
              }
          }
          if (arr[low] == element) {
              return low;
          } else if (arr[high] == element) {
              return high;
          }
          return -1;
      }
  
      static int lower_bound(int[] arr, int l, int r, int element) {
          int low = l;
          int high = r;
          while (high - low > 1) {
              int mid = low + (high - low) / 2;
              if (arr[mid] < element) {
                  low = mid + 1;
              } else {
                  high = mid;
              }
          }
          if (arr[low] >= element) {
              return low;
          } else if (arr[high] >= element) {
              return high;
          }
          return -1;
      }
  
      static int upper_bound(int[] arr, int l, int r, int element) {
          int low = l;
          int high = r;
          while (high - low > 1) {
              int mid = low + (high - low) / 2;
              if (arr[mid] <= element) {
                  low = mid + 1;
              } else {
                  high = mid;
              }
          }
          if (arr[low] > element) {
              return low;
          } else if (arr[high] > element) {
              return high;
          }
          return -1;
      }
      public static long pow(long a,long b){
          if(b==1)return a;
          if(b==0l)return 1l;
          if(a==1l)return a;
          if(b%2l==1l){
              a=a*a;
              b--;
          }
          long hs=pow(a,b/2l);
          return hs*hs;
      }
      public static long gcd_long(long a,long b){
          //a/b,a-> dividant b-> divisor
          if(b==0)return a;
          return gcd_long(b, a%b);
      }
      public static int gcd_int(int a,int b){
          //a/b,a-> dividant b-> divisor
          if(b==0)return a;
          return gcd_int(b, a%b);
      }
      public static int lcm(int a,int b){
          int gcd=gcd_int(a, b);
          return (a*b)/gcd;
      }
  
      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());
          }
  
          String nextLine() {
              String s = "";
              try {
                  s = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return s;
          }
  
          Long nextLong() {
              return Long.parseLong(next());
          }
      }
  
  /*JAVA STRING CONTAINS METHOD--------->str1.contains(str2)-->if(str2 is present in str1){
                                                                    return true; 
                                                              }
                                                              else return false;
  */
  
  
  public static boolean contains(String main, String Substring) {
      boolean flag=false;
      if(main==null && main.trim().equals("")) {
          return flag;
      }
      if(Substring==null) {
          return flag;
      }
  
      char fullstring[]=main.toCharArray();
      char sub[]=Substring.toCharArray();
      int counter=0;
      if(sub.length==0) {
          flag=true;
          return flag;
      }
  
      for(int i=0;i<fullstring.length;i++) {
  
          if(fullstring[i]==sub[counter]) {
              counter++;
          } else {
              counter=0;
          }
  
          if(counter==sub.length) {
              flag=true;
              return flag;
          }
  
      }
      return flag;
  
  }
  
  
  }
  
  /*
   * public static boolean lie(int n,int m,int k){ if(n==1 && m==1 && k==0){
   * return true; } if(n<1 || m<1 || k<0){ return false; } boolean
   * tc=lie(n-1,m,k-m); boolean lc=lie(n,m-1,k-n); if(tc || lc){ return true; }
   * return false; }
   */
  
  