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 \cdot 1 + 5 \cdot 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 \le t \le 10^4$) — number of test cases.

The first line of each test case contains two integers $n$ and $k$ ($1 \le n \le 10; 1 \le k \le 10^9$).

The next line contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 = a_1 < a_2 < \dots < a_n \le 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.


-----Examples-----

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


-----Note-----

None

Source: codeforces | Difficulty: MEDIUM
Tags: Number theory

Greedy algorithms


Solutions:
def solve():
	(n, k) = list(map(int, input().split()))
	k += 1
	ans = 0
	arr = list(map(int, input().split()))
	for i in range(n - 1):
		if k > 0:
			x = pow(10, arr[i + 1] - arr[i]) - 1
			val = min(x, k)
			ans += pow(10, arr[i]) * val
			k -= val
	ans += k * pow(10, arr[n - 1])
	print(ans)
t = int(input())
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	az = [int(x) for x in input().split()]
	max_n = []
	for i in range(len(az) - 1):
		max_n.append(10 ** (az[i + 1] - az[i]) - 1)
	res = 0
	for i in range(len(az) - 1):
		l = min(k + 1, max_n[i])
		k -= l
		res += l * 10 ** az[i]
		if k == -1:
			break
	if k >= 0:
		res += (k + 1) * 10 ** az[-1]
	print(res)


from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
import math
from copy import deepcopy
from itertools import combinations, permutations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
import sys

def input():
	return sys.stdin.readline().rstrip()

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getListGraph():
	return list(map(lambda x: int(x) - 1, input().split()))

def getArray(intn):
	return [int(input()) for i in range(intn)]
mod = 10 ** 9 + 7
MOD = 998244353
inf = float('inf')
eps = 10 ** (-10)
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]
T = getN()
for _ in range(T):
	(N, K) = getNM()
	A = [10 ** a for a in getList()]
	A.append(10 ** 18)
	for i in range(N):
		lim = A[i + 1] // A[i] - 1
		if K >= lim:
			K -= lim
			continue
		else:
			print((K + 2) * A[i] - 1)
			break


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	if n == 1:
		print(k + 1)
		continue
	maxn = []
	for i in range(n - 1):
		maxn.append(10 ** (a[i + 1] - a[i]) - 1)
	c = 0
	s = 0
	flag = False
	for i in range(n - 1):
		if c + maxn[i] > k:
			flag = True
			break
		c += maxn[i]
		s += maxn[i] * 10 ** a[i]
	if not flag:
		i += 1
	s += (k - c + 1) * 10 ** a[i]
	print(s)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	(n, k) = ma()
	a = lis()
	if n == 1:
		print(k + 1)
		continue
	fl = 0
	k += 1
	res = ''
	for i in range(n - 1):
		ra = 10 ** a[i + 1] - 1
		curmo = 0
		num = ra
		for j in range(i, -1, -1):
			ra1 = ra // 10 ** a[j]
			curmo += ra1
			ra = ra % 10 ** a[j]
		if curmo < k:
			continue
		else:
			z1 = 10 ** a[i] - 1
			res = str(z1)
			moves = 0
			ra = z1
			for j in range(i - 1, -1, -1):
				ra1 = ra // 10 ** a[j]
				moves += ra1
				ra = ra % 10 ** a[j]
			rem = k - moves
			if int(res) != 0:
				res = str(rem) + res
			else:
				res = str(rem)
			fl = 1
			break
	if fl == 0:
		z1 = 10 ** a[-1] - 1
		res = str(z1)
		moves = 0
		ra = z1
		for j in range(n - 2, -1, -1):
			ra1 = ra // 10 ** a[j]
			moves += ra1
			ra = ra % 10 ** a[j]
		rem = k - moves
		if int(res):
			res = str(rem) + res
		else:
			res = str(rem)
		fl = 1
	print(int(res))


import math

def solve(A, l):
	numb = 0
	remind = l
	while remind > 0:
		if A:
			x = A.pop(0)
			if A:
				t = (10 ** A[0] - 10 ** x) / 10 ** x
				r = int(min(t, remind))
				numb += int(r * 10 ** x)
				remind -= r
			if not A:
				numb += int(remind * 10 ** x)
				remind = 0
	print(int(numb))
t = int(input())
for i in range(t):
	(n, l) = list(map(int, input().strip().split()))
	l += 1
	A = list(map(int, input().strip().split()))
	solve(A, l)


from collections import defaultdict as dc

def mlt():
	return map(int, input().split())

def solv():
	(x, y) = mlt()
	s = sorted([*mlt()])
	y += 1
	if x == 1:
		print(y)
		return
	res = 0
	for n in range(x - 1):
		if not y:
			break
		curPow = s[n]
		nextPow = s[n + 1]
		dif = nextPow - curPow
		a = 10 ** dif - 1
		dif = min(a, y)
		y -= dif
		res += dif * 10 ** s[n]
	if y:
		res += y * 10 ** s[-1]
	print(res)
for _ in range(int(input())):
	solv()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split(' '))
	A = list(map(int, input().split(' ')))
	if n == 1:
		r = k + 1
	else:
		B = [0] * n
		for i in range(n - 1):
			B[i] = 10 ** (A[i + 1] - A[i]) - 1
		B[n - 1] = 10 ** 20
		if k < B[0]:
			r = k + 1
		else:
			k += 1
			Z = [0] * n
			for i in range(n):
				Z[i] = min(B[i], k)
				k -= Z[i]
			r = 0
			for i in range(n):
				r += 10 ** A[i] * Z[i]
	print(r)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	m = [0 for i in range(n - 1)]
	for i in range(n - 1):
		m[i] = 10 ** (a[i + 1] - a[i]) - 1
	ans = 0
	for i in range(n - 1):
		if k >= m[i]:
			ans += m[i] * 10 ** a[i]
			k -= m[i]
		else:
			ans += (k + 1) * 10 ** a[i]
			k = -1
			break
	if k >= 0:
		ans += (k + 1) * 10 ** a[n - 1]
	print(ans)


t = int(input())
import sys
for i in range(t):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	den = [10 ** x for x in l1]
	avail = []
	j = 1
	while j < len(den):
		avail.append(den[j] // den[j - 1] - 1)
		j += 1
	avail.append(10000000000000000000000)
	ans = 0
	z = 0
	k += 1
	while k:
		l = min(k, avail[z])
		ans += den[z] * l
		k -= l
		z += 1
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	a = sorted(list(map(int, input().split(' '))))
	s = 0
	number = 0
	k += 1
	for p in range(n - 1):
		t = 10 ** (a[p + 1] - a[p]) - 1
		if t < k:
			k -= t
			number += t * 10 ** a[p]
		else:
			number += k * 10 ** a[p]
			k = 0
			break
	if k:
		number += 10 ** a[-1] * k
	print(number)


import io, os, sys
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
output = sys.stdout.write
ten_powers = [10 ** i for i in range(11)]

def solve(N, K, pows):
	costs = [0] * N
	for i in range(1, N):
		costs[i] = 10 ** (pows[i] - pows[i - 1]) - 1 + costs[i - 1]
	i = 1
	while i < N:
		if costs[i] > K:
			break
		i += 1
	return (K - costs[i - 1] + 1) * 10 ** pows[i - 1] + 10 ** pows[i - 1] - 1

def main():
	T = int(input())
	for _ in range(T):
		(N, K) = list(map(int, input().split()))
		pows = list(map(int, input().split()))
		out = solve(N, K, pows)
		output(str(out) + '\n')
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	number = 0
	cost = 0
	i = 0
	while cost <= k:
		if i == len(p) - 1:
			q = k - cost + 1
		else:
			z = 10 ** p[i + 1] - 10 ** p[i]
			z = z // 10 ** p[i]
			q = min(k - cost + 1, z)
		number += 10 ** p[i] * q
		cost += q
		i += 1
	print(number)


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	(n, k) = M()
	k += 1
	l = L()
	s = ''
	i = 0
	while i < n and k > 0:
		if i + 1 < n:
			a = '9' * (l[i + 1] - l[i])
			if k >= int(a):
				k -= int(a)
				s += a
			else:
				s += str(k)[::-1]
				break
			i += 1
		else:
			s += str(k)[::-1]
			break
	print(s[::-1])


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	(n, k) = INL()
	X = INL()
	k += 1
	ans = 0
	_ = 0
	while 0 < k and _ + 1 < n:
		ans += 10 ** X[_] * min(10 ** (X[_ + 1] - X[_]) - 1, k)
		k -= min(10 ** (X[_ + 1] - X[_]) - 1, k)
		_ += 1
	OPS(ans + k * 10 ** X[n - 1])


def f():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.append(30)
	j = 0
	k += 1
	cnt = 10 ** (a[j + 1] - a[j]) - 1
	while cnt < k:
		j += 1
		cnt += 10 ** (a[j + 1] - a[j]) - 1
	cnt -= 10 ** (a[j + 1] - a[j]) - 1
	ans = 10 ** a[j] - 1
	k -= cnt
	ans += k * 10 ** a[j]
	print(ans)
t = int(input())
for i in range(t):
	f()


_ = int(input())
for __ in range(_):
	(n, k) = map(int, input().split())
	k += 1
	l = list(map(int, input().split()))
	values = [10 ** x for x in l]
	num_of_b = []
	out = 0
	if n == 1:
		print(k)
		continue
	for x in range(1, n):
		num_of_b.append(values[x] // values[x - 1] - 1)
	for x in range(0, n - 1):
		if k >= num_of_b[x]:
			out += num_of_b[x] * values[x]
			k -= num_of_b[x]
		else:
			out += values[x] * k
			k = 0
			break
	if k:
		out += k * values[-1]
	print(out)


t = int(input())
for tt in range(t):
	(n, k) = [int(s) for s in input().split()]
	a = [int(s) for s in input().split()]
	k_tot = 0
	s = 0
	for i in range(n):
		ai_val = 10 ** a[i]
		ki = k - k_tot + 1
		if i < n - 1:
			ki = min(ki, 10 ** (a[i + 1] - a[i]) - 1)
		k_tot += ki
		s += ai_val * ki
		if k_tot > k:
			break
	print(s)


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	k += 1
	steps = list(map(lambda x: 10 ** int(x), input().split()))
	ans = 0
	for i in range(0, n - 1):
		count = steps[i + 1] // steps[i] - 1
		ans += min(count, k) * steps[i]
		k -= min(count, k)
	ans += k * steps[n - 1]
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	k += 1
	a = list(map(int, input().split()))
	for i in range(len(a)):
		a[i] = 10 ** a[i]
	i = s = c = 0
	while i < n - 1 and c < k:
		c += a[i + 1] // a[i] - 1
		s += (a[i + 1] // a[i] - 1) * a[i]
		i += 1
	if c < k:
		s += (k - c) * a[i]
	else:
		s -= (c - k) * a[i - 1]
	print(s)


def solve():
	(n, k) = map(int, input().split())
	k += 1
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		p = pow(10, a[i + 1] - a[i]) - 1
		p = min(k, p)
		ans += pow(10, a[i]) * p if k > 0 else 0
		k -= p
		if k == 0:
			break
	ans += pow(10, a[-1]) * k
	return ans
for _ in range(int(input())):
	print(solve())


from math import ceil, pow
tests = int(input())
for testcase in range(tests):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	ans = 0
	c = 0
	for (i, e) in enumerate(a):
		if i == n - 1:
			ans += int(pow(10, a[i]) * (k - c + 1))
			print(int(ans))
			break
		u = pow(10, a[i + 1] - a[i])
		if k - c < u - 1:
			ans += int(pow(10, a[i]) * (k - c))
			print(int(ans + pow(10, a[i])))
			break
		elif k - c == u - 1:
			ans += int(pow(10, a[i]) * (k - c))
			print(int(ans + pow(10, a[i + 1])))
			break
		else:
			ans += int(pow(10, a[i]) * (u - 1))
			c += u - 1


import os
import sys
from io import BytesIO, IOBase
from bisect import bisect_left
from math import gcd, log, ceil
from collections import Counter
from pprint import pprint
import heapq
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	n = len(arr)
	if n == 1:
		return k + 1
	vals = [-1 for _ in range(n)]
	start = 0
	for i in range(start, n - 1):
		if k <= 0:
			break
		next_val = 10 ** arr[i + 1]
		if i == 0:
			max_remove = next_val // 10 ** arr[i] - 2
		else:
			max_remove = next_val // 10 ** arr[i] - 1
		vals[i] = min(max_remove, k)
		k -= max_remove
	ans = 0
	for i in range(n - 1):
		ans += 10 ** arr[i] * max(vals[i], 0)
	if k > 0:
		ans += 10 ** arr[-1] * k
	return ans + 1
for _ in range(int(input())):
	ans = main()
	print(ans)


import sys
max_int = sys.maxsize

def f(n):
	return pow(10, n)
t = int(input())
for x in range(t):
	S = list(map(int, input().strip().split()))
	n = S[0]
	k = S[1]
	L = list(map(int, input().strip().split()))
	M = list(map(f, L))
	ST = []
	for y in range(n - 1):
		ST = ST + [M[y + 1] // M[y] - 1]
	ST = ST + [max_int]
	a = k + 1
	b = 0
	total = 0
	while a > 0:
		if a >= ST[b]:
			total = total + ST[b] * M[b]
			a = a - ST[b]
			b = b + 1
		else:
			total = total + a * M[b]
			a = 0
	print(total)


import math
import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
BUFSIZE = 8192
from bisect import bisect_left
from bisect import bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import deque

def ceil(a, b):
	if a <= 0:
		return 0
	if a % b == 0:
		return a // b
	else:
		return a // b + 1
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	b = list(map(int, input().split()))
	if n == 1:
		print(k + 1)
	else:
		j = 0
		ans = 0
		k += 1
		while j < n - 1:
			d = b[j + 1] - b[j]
			r = 10 ** d - 1
			if r >= k:
				ans += k * 10 ** b[j]
				k = 0
				break
			else:
				k -= r
				ans += r * 10 ** b[j]
			j += 1
		ans += k * 10 ** b[n - 1]
		print(ans)


cases = int(input())
for i in range(cases):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	kk = k + 1
	b = []
	c = 0
	for ii in range(len(a) - 1):
		b.append(10 ** (a[ii + 1] - a[ii]) - 1)
	for iii in range(len(b)):
		if b[iii] < kk:
			c += b[iii] * 10 ** a[iii]
			kk -= b[iii]
		else:
			c += kk * 10 ** a[iii]
			kk = 0
			print(c)
			break
	if kk > 0:
		print(c + kk * 10 ** a[-1])


BIG = 30

def solve(n, k, a):
	a.append(BIG)
	k += 1
	num = 0
	for i in range(1, n + 1):
		quant = min(k, 10 ** (a[i] - a[i - 1]) - 1)
		k -= quant
		num += 10 ** a[i - 1] * quant
		if k == 0:
			break
	assert k == 0
	print(num)

def read():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	solve(n, k, a)
for tcase in range(int(input())):
	read()


def solve():
	(n, k) = map(int, input().split())
	arr = list(map(lambda x: 10 ** x, map(int, input().split())))
	i = 0
	res = 0
	k += 1
	while i < len(arr) - 1:
		diff = arr[i + 1] // arr[i] - 1
		if k <= diff:
			res += k * arr[i]
			k = 0
			break
		else:
			res += arr[i] * diff
			k -= diff
			i += 1
	if k > 0:
		res += k * arr[-1]
	print(res)

def prob():
	for i in range(int(input())):
		solve()
prob()


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
for _ in range(rn()):
	(n, k) = rns()
	a = rl()
	b = []
	for i in range(n - 1):
		b.append(10 ** (a[i + 1] - a[i]) - 1)
	ans = 0
	while len(b) > 0 and k >= b[0]:
		ans += b[0] * 10 ** a[0]
		k -= b.pop(0)
		a.pop(0)
	if k >= 0:
		if len(b) == 0:
			last = a.pop(0)
			ans += (k + 1) * 10 ** last
		else:
			ans += (k + 1) * 10 ** a.pop(0)
	print(ans)


for test in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	denom = []
	for i in arr:
		denom.append(10 ** i)
	ans = []
	for i in range(n - 1):
		max_val = denom[i + 1] // denom[i] - 1
		if k > max_val:
			k -= max_val
			ans.append(max_val * denom[i])
		elif k == max_val:
			ans.append(max_val * denom[i])
			ans.append(denom[i + 1])
			k = 0
			break
		else:
			ans.append(denom[i] * (k + 1))
			k = 0
			break
	if k != 0:
		ans.append(denom[-1] * (k + 1))
	print(sum(ans))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	mas = list(map(int, input().split()))
	out = 0
	z = 0
	k += 1
	for i in range(len(mas) - 1):
		if z != k:
			out += 10 ** mas[i] * min(k - z, 10 ** (mas[i + 1] - mas[i]) - 1)
			z += min(k - z, 10 ** (mas[i + 1] - mas[i]) - 1)
		else:
			break
	if z != k:
		out += 10 ** mas[-1] * (k - z)
	print(out)


from math import sqrt, gcd, ceil, floor, log, factorial
from itertools import permutations, combinations
from collections import Counter, defaultdict
import collections, sys, threading
import collections, sys, threading
from bisect import *
from heapq import *

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def msi():
	return map(str, input().split())

def li():
	return list(mi())
t = ii()
for _ in range(t):
	(n, k) = mi()
	a = li()
	av = [0] * (n - 1)
	pre = [0] * (n - 1)
	money = [0] * (n - 1)
	for i in range(n - 1):
		av[i] = pow(10, a[i + 1]) - pow(10, a[i])
		pre[i] = av[i] // pow(10, a[i]) + pre[i - 1]
		money[i] = money[i - 1] + av[i]
	flag = 0
	for i in range(n - 2, -1, -1):
		if k >= pre[i]:
			req = k - pre[i] + 1
			flag = 1
			print(req * pow(10, a[i + 1]) + money[i])
			break
	if flag == 0:
		print(k + 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	w = [10 ** int(x) for x in input().split()] + [10 ** 18]
	(a, i) = (0, 0)
	k += 1
	while k > 0:
		l = w[i + 1] // w[i] - 1
		a += w[i] * min(k, l)
		k -= l
		i += 1
	print(a)


import math
tt = int(input())
ANS = []
while tt > 0:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = [int(i) for i in input().split()]
	b = []
	for i in range(n - 1):
		b.append(pow(10, a[i + 1] - a[i]) - 1)
	ans = 0
	cnt = 0
	ind = n - 1
	for i in range(n - 1):
		if cnt + b[i] >= k + 1:
			ind = i
			break
		cnt += b[i]
	kk = k + 1 - cnt
	for i in range(ind):
		ans += pow(10, a[i]) * b[i]
	ans += kk * pow(10, a[ind])
	ANS.append(ans)
	tt -= 1
for ans in ANS:
	print(ans)


t = int(input())
for _ in range(t):
	(n, K) = map(int, input().split())
	K += 1
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		tmp = min(K, 10 ** (a[i + 1] - a[i]) - 1)
		K -= tmp
		ans += tmp * 10 ** a[i]
		if K == 0:
			break
	if K > 0:
		ans += K * 10 ** a[n - 1]
	print(ans)


def solve():
	(n, k) = map(int, input().split())
	denom = list(map(int, input().split()))
	ans = 0
	for i in range(n - 1):
		res = 10 ** (denom[i + 1] - denom[i]) - 1
		if res > k:
			ans += (k + 1) * 10 ** denom[i]
			return ans
		elif res == k:
			ans += k * 10 ** denom[i] + 10 ** denom[i + 1]
			return ans
		else:
			ans += res * 10 ** denom[i]
			k -= res
	return ans + (k + 1) * 10 ** denom[-1]
t = int(input())
for _ in range(t):
	print(solve())


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	l = [int(i) for i in input().split()]
	ans = ''
	last = k
	for i in range(n - 1):
		if last >= 10 ** (l[i + 1] - l[i]) - 1:
			ans = '9' * (l[i + 1] - l[i]) + ans
			last -= int('9' * (l[i + 1] - l[i]))
		else:
			break
	print(str(last + 1) + ans)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
from typing import Counter
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def main():
	t = int(input())
	while t:
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		canUse = []
		for i in range(n - 1):
			canUse.append(int(10 ** a[i + 1] / 10 ** a[i] - 1))
		canUse.append(float('inf'))
		i = 0
		ans = []
		while canUse[i] <= k:
			k -= canUse[i]
			ans.append(canUse[i])
			i += 1
		ans.append(k + 1)
		ans = ans[::-1]
		out = ''
		for i in ans:
			out += str(i)
		print(int(out))
		t -= 1
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
INF = 10 ** 10

def solve(N, K, A):
	ans = 0
	A += [20]
	K += 1
	for i in range(N):
		if K < 10 ** (A[i + 1] - A[i]):
			ans += K * 10 ** A[i]
			return ans
		else:
			v = 10 ** (A[i + 1] - A[i]) - 1
			ans += v * 10 ** A[i]
			K -= v
	return ans
T0 = int(input())
for _ in range(T0):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	print(solve(N, K, A))


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	pw = [int(x) for x in input().split()]
	val = [10 ** (pw[i + 1] - pw[i]) - 1 for i in range(len(pw) - 1)]
	(s, ii) = (0, 0)
	for i in range(len(val)):
		if k >= val[i]:
			k -= val[i]
			s += val[i] * 10 ** pw[i]
			ii = i + 1
		else:
			break
	s += 10 ** pw[ii] * (k + 1)
	print(s)


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split(' '))
	a = [10 ** int(i) for i in input().split(' ')]
	count = k + 1
	i = 0
	ans = 0
	while count > 0:
		if i < len(a) - 1:
			maxb = (a[i + 1] - a[i]) // a[i]
		else:
			maxb = count
		if maxb > count:
			maxb = count
		count -= maxb
		ans += maxb * a[i]
		i += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	res = ''
	k += 1
	for i in range(1, n):
		if k >= 10 ** (a[i] - a[i - 1]) - 1:
			k -= 10 ** (a[i] - a[i - 1]) - 1
			res = '9' * (a[i] - a[i - 1]) + res
		else:
			res = str(k) + res
			k = 0
		if k == 0:
			break
	if k > 0:
		res = str(k) + res
	print(res)


def solve(n, k, a):
	for _ in range(a[0]):
		print('0', end='')
	i = 0
	s = []
	while k > 0 and i < n - 1:
		count = min(k, pow(10, a[i + 1] - a[i]) - 1)
		s.append(count)
		k = k - count
		i = i + 1
	if k > 0:
		s.append(k)
	i = len(s) - 1
	while i >= 0:
		print(s[i], end='')
		i = i - 1
	print()
T = int(input())
for _ in range(T):
	(n, k) = input().split()
	n = int(n)
	k = int(k) + 1
	a = [int(i) for i in input().split()]
	solve(n, k, a)


T = int(input())
import math
for _ in range(T):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split())) + [18]
	k += 1
	ans = 0
	for i in range(n):
		d = min(k, pow(10, A[i + 1] - A[i]) - 1)
		k -= d
		ans += d * pow(10, A[i])
		if not k:
			break
	print(ans)


import os
import sys
import math
from io import BytesIO, IOBase
import io
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
from collections import Counter
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10001)]
prime[0] = prime[1] = False

def SieveOfEratosthenes(n=10000):
	p = 2
	c = 0
	while p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				prime[i] = False
		p += 1

class DSU:

	def __init__(self, R, C):
		self.par = range(R * C + 1)
		self.rnk = [0] * (R * C + 1)
		self.sz = [1] * (R * C + 1)

	def find(self, x):
		if self.par[x] != x:
			self.par[x] = self.find(self.par[x])
		return self.par[x]

	def union(self, x, y):
		(xr, yr) = (self.find(x), self.find(y))
		if xr == yr:
			return
		if self.rnk[xr] < self.rnk[yr]:
			(xr, yr) = (yr, xr)
		if self.rnk[xr] == self.rnk[yr]:
			self.rnk[xr] += 1
		self.par[yr] = xr
		self.sz[xr] += self.sz[yr]

	def size(self, x):
		return self.sz[self.find(x)]

	def top(self):
		return self.size(len(self.sz) - 1) - 1

class LazySegTree:

	def __init__(self, _op, _e, _mapping, _composition, _id, v):

		def set(p, x):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			_d[p] = x
			for i in range(1, _log + 1):
				_update(p >> i)

		def get(p):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			return _d[p]

		def prod(l, r):
			assert 0 <= l <= r <= _n
			if l == r:
				return _e
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r >> i)
			sml = _e
			smr = _e
			while l < r:
				if l & 1:
					sml = _op(sml, _d[l])
					l += 1
				if r & 1:
					r -= 1
					smr = _op(_d[r], smr)
				l >>= 1
				r >>= 1
			return _op(sml, smr)

		def apply(l, r, f):
			assert 0 <= l <= r <= _n
			if l == r:
				return
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r - 1 >> i)
			l2 = l
			r2 = r
			while l < r:
				if l & 1:
					_all_apply(l, f)
					l += 1
				if r & 1:
					r -= 1
					_all_apply(r, f)
				l >>= 1
				r >>= 1
			l = l2
			r = r2
			for i in range(1, _log + 1):
				if l >> i << i != l:
					_update(l >> i)
				if r >> i << i != r:
					_update(r - 1 >> i)

		def _update(k):
			_d[k] = _op(_d[2 * k], _d[2 * k + 1])

		def _all_apply(k, f):
			_d[k] = _mapping(f, _d[k])
			if k < _size:
				_lz[k] = _composition(f, _lz[k])

		def _push(k):
			_all_apply(2 * k, _lz[k])
			_all_apply(2 * k + 1, _lz[k])
			_lz[k] = _id
		_n = len(v)
		_log = _n.bit_length()
		_size = 1 << _log
		_d = [_e] * (2 * _size)
		_lz = [_id] * _size
		for i in range(_n):
			_d[_size + i] = v[i]
		for i in range(_size - 1, 0, -1):
			_update(i)
		self.set = set
		self.get = get
		self.prod = prod
		self.apply = apply
MIL = 1 << 20

def makeNode(total, count):
	return total * MIL + count

def getTotal(node):
	return math.floor(node / MIL)

def getCount(node):
	return node - getTotal(node) * MIL
nodeIdentity = makeNode(0.0, 0.0)

def nodeOp(node1, node2):
	return node1 + node2
	return makeNode(getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2))
identityMapping = -1

def mapping(tag, node):
	if tag == identityMapping:
		return node
	count = getCount(node)
	return makeNode(tag * count, count)

def composition(mapping1, mapping2):
	return mapping1 if mapping1 != identityMapping else mapping2

class LazySegUpdate:

	def __init__(self, N):
		self.N = N
		n = 4 * N
		self.tree = [0] * n
		self.lazy = [0] * n

	def queryHelper(self, index, s, e, l, r):
		if self.lazy[index]:
			update = self.lazy[index]
			self.lazy[index] = 0
			self.tree[index] = max(self.tree[index], update)
			if s != e:
				self.lazy[2 * index] = max(self.lazy[2 * index], update)
				self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], update)
		if s > e or s > r or e < l:
			return 0
		if s >= l and e <= r:
			return self.tree[index]
		mid = (s + e) // 2
		return max(self.queryHelper(2 * index, s, mid, l, r), self.queryHelper(2 * index + 1, mid + 1, e, l, r))

	def updateHelper(self, index, s, e, l, r, h):
		if self.lazy[index]:
			update = self.lazy[index]
			self.lazy[index] = 0
			self.tree[index] = max(self.tree[index], update)
			if s != e:
				self.lazy[2 * index] = max(self.lazy[2 * index], update)
				self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], update)
		if s > e or s > r or e < l:
			return
		if s >= l and e <= r:
			self.tree[index] = max(self.tree[index], h)
			if s != e:
				self.lazy[2 * index] = max(self.lazy[2 * index], h)
				self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], h)
			return
		mid = (s + e) // 2
		self.updateHelper(2 * index, s, mid, l, r, h)
		self.updateHelper(2 * index + 1, mid + 1, e, l, r, h)
		self.tree[index] = max(self.tree[2 * index], self.tree[2 * index + 1])

	def query(self, l, r):
		return self.queryHelper(1, 0, self.N - 1, l, r - 1)

	def update(self, l, r, h):
		self.updateHelper(1, 0, self.N - 1, l, r - 1, h)

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return math.gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = math.gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = math.gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = n
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] >= key:
			res = mid
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = -1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
t = 1
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	k += 1
	for i in range(n):
		if i != n - 1:
			avl = min(k, 10 ** (a[i + 1] - a[i]) - 1)
			k -= avl
			ans += avl * 10 ** a[i]
		else:
			ans += k * 10 ** a[i]
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	k += 1
	a = list(map(int, input().split()))
	ans = 0
	for j in range(n - 1):
		z = pow(10, a[j + 1] - a[j]) - 1
		if k >= z:
			k -= z
			ans += pow(10, a[j]) * z
		else:
			ans += pow(10, a[j]) * k
			k = 0
			break
	ans += pow(10, a[n - 1]) * k
	print(ans)


from array import array
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = array('b', map(int, input().split()))
	ai1 = 0
	left = k + 1
	for ai in a:
		used_here = 10 ** (ai - ai1) - 1
		if left <= used_here:
			break
		left -= used_here
		ai1 = ai
	print(left, '9' * ai1, sep='')


import math
test_cases = int(input())
for i in range(0, test_cases):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	A = input().split()
	amount = 0
	count = 0
	for j in range(0, n - 1):
		if count <= k:
			diff = k - count + 1
			temp = (int(pow(10, int(A[j + 1]))) - int(pow(10, int(A[j])))) // int(pow(10, int(A[j])))
			if diff >= temp:
				amount = amount + pow(10, int(A[j + 1])) - pow(10, int(A[j]))
				count = count + temp
			else:
				amount = amount + diff * pow(10, int(A[j]))
				count = count + diff
	diff = k - count + 1
	if diff > 0:
		amount = amount + diff * pow(10, int(A[n - 1]))
		count = count + diff
	print(amount)


t = int(input())
for test in range(0, t):
	(n, k) = map(int, input().strip().split())
	req = k + 1
	target = 0
	alpha = list(map(int, input().strip().split()))
	mdp = []
	for i in range(0, n - 1):
		y = alpha[i + 1] - alpha[i]
		mdp.append(10 ** y - 1)
	mdp.append(10 ** 10)
	start = 0
	while req > 0:
		temp_req = req
		dnom = 10 ** alpha[start]
		req = temp_req - min(req, mdp[start])
		target += min(temp_req, mdp[start]) * dnom
		start += 1
	print(target)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	m += 1
	A = list(map(int, input().split()))
	A.append(18)
	ans = ''
	for i in range(n):
		if 10 ** (A[i + 1] - A[i]) - 1 >= m:
			ans = str(m) + ans
			break
		else:
			ans += str(10 ** (A[i + 1] - A[i]) - 1)
			m -= 10 ** (A[i + 1] - A[i]) - 1
	print(ans)


for u in range(int(input())):
	(n, k) = map(int, input().split())
	x = [int(w) for w in input().split()]
	ans = 0
	k += 1
	for i in range(n - 1):
		if k > 0:
			temp = 10 ** (x[i + 1] - x[i]) - 1
			ans += 10 ** x[i] * min(temp, k)
			k -= min(temp, k)
	ans += k * 10 ** x[n - 1]
	print(ans)


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	k += 1
	mi = 0
	for i in range(n - 1):
		if k > 0:
			now = 10 ** (arr[i + 1] - arr[i]) - 1
			pre = min(now, k)
			mi += 10 ** arr[i] * pre
			k -= pre
	mi += k * 10 ** arr[n - 1]
	print(mi)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	val = [0] * n
	coins = [0] * n
	for i in range(n - 1):
		coins[i] += (10 ** l[i + 1] - 10 ** l[i]) // 10 ** l[i]
	req = [0] * n
	k += 1
	c = 0
	ans = 0
	while k > coins[c]:
		k -= coins[c]
		req[c] += coins[c]
		c += 1
		if c == n:
			break
	if c == n:
		for i in range(n - 1):
			ans += 10 ** l[i] * coins[i]
		ans += 10 ** l[n - 1] * k
	else:
		for i in range(c):
			ans += 10 ** l[i] * coins[i]
		ans += 10 ** l[c] * k
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = [int(x) for x in input().split()]
	x = 0
	k += 1
	for i in range(n):
		if i == n - 1:
			d = k
		else:
			d = min(k, 10 ** (A[i + 1] - A[i]) - 1)
		x += d * 10 ** A[i]
		k -= d
	print(x)


from collections import deque

def f(s, a):
	ans = 0
	a = sorted(a, reverse=True)
	q = deque(a)
	while s:
		bill = q.popleft()
		while bill > s:
			bill = q.popleft()
		ans += s // bill
		s %= bill
	return ans
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [10 ** i for i in a]
	goal = k + 1
	i = 0
	bill = b[i]
	test = 0
	notes = f(test, b)
	while notes < goal:
		rem = goal - notes
		if i == n - 1:
			test += rem * bill
			notes = f(test, b)
		else:
			i += 1
			bill = b[i]
			test += min(rem, bill // b[i - 1] - 1) * b[i - 1]
			notes = f(test, b)
	print(test)


t = int(input())
for cyc in range(t):
	(n, k) = map(int, input().split())
	a = [10 ** int(i) for i in input().split()]
	a = sorted(a)
	a.append(10 ** 20)
	cur = 0
	for i in range(n):
		cur1 = cur
		cur += a[i + 1] // a[i] - 1
		if cur > k:
			print(a[i] * (k - cur1 + 2) - 1)
			break


t = int(input())
for sdaskljdkj in range(t):
	(n, k) = [int(i) for i in input().split()]
	l = [int(i) for i in input().split()]
	ans = ''
	last = k + 1
	for i in range(n - 1):
		if last == 0:
			break
		if last >= 10 ** (l[i + 1] - l[i]) - 1:
			ans = '9' * (l[i + 1] - l[i]) + ans
			last -= int('9' * (l[i + 1] - l[i]))
		else:
			ans = str(last) + ans
			last = 0
			break
	if last == 0:
		print(ans)
	else:
		print(str(last) + ans)


from decimal import *

def bankNotes(n, k, notes):
	count = [0] * 10
	i = 0
	while i < n - 1:
		req = Decimal(10 ** notes[i + 1] - 10 ** notes[i]) / Decimal(10 ** notes[i])
		if req <= k:
			k -= req
			count[notes[i]] = req
			i += 1
			if k == 0:
				count[notes[i]] += 1
				break
		else:
			count[notes[i]] = k + 1
			k = 0
			break
	if k > 0:
		count[notes[-1]] += k + 1
	ans = 0
	for x in range(10):
		ans += 10 ** x * count[x]
	return int(ans)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	print(bankNotes(n, k, l))


import sys
import math

def inpu():
	return sys.stdin.readline()

def po(n):
	ij = 1
	for jj in range(n):
		ij *= 10
	return ij
T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	done = False
	k += 1
	a.sort()
	ca = 0
	cca = [0] * n
	for i in range(n - 1):
		if ca + (po(a[i + 1] - a[i]) - 1) >= k:
			cca[i] = k - ca
			done = True
			break
		else:
			l = po(a[i + 1] - a[i]) - 1
			cca[i] = l
			ca += l
	ans = 0
	for i in range(n - 1, -1, -1):
		ans += po(a[i]) * cca[i]
	if not done:
		ans += po(a[-1]) * (k - ca)
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	coin = list(map(int, input().split()))
	ans = 0
	amount = 0
	i = 0
	k += 1
	while k > 0:
		if i == n - 1:
			amount += k * 10 ** coin[-1]
			ans += k
			break
		t = (10 ** coin[i + 1] - 1) // 10 ** coin[i]
		amount += min(t, k) * 10 ** coin[i]
		ans += min(t, k)
		k -= min(t, k)
		i += 1
	print(amount)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	num = [10 ** arr[i] for i in range(n)]
	if arr[0] != 0:
		print(1)
		continue
	s = ''
	maxd = []
	for i in range(n - 1):
		dd = arr[i + 1] - arr[i]
		el = '9' * dd
		maxd += [int(el)]
	money = 0
	for i in range(len(maxd)):
		if maxd[i] > k:
			diff = k + 1
			money += diff * 10 ** arr[i]
			k = -1
			break
		else:
			money += maxd[i] * 10 ** arr[i]
			k -= maxd[i]
	if k >= 0:
		k += 1
		money += k * 10 ** arr[-1]
	print(money)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	notes = list(map(int, input().split()))
	money = 0
	k += 1
	for i in range(n - 1):
		if k == 0:
			break
		bills = (10 ** notes[i + 1] - 10 ** notes[i]) // 10 ** notes[i]
		if k > bills:
			money += bills * 10 ** notes[i]
			k -= bills
		else:
			money += k * 10 ** notes[i]
			k -= k
	if k > 0:
		money += k * 10 ** notes[-1]
	print(money)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k += 1
	a = list(map(int, input().split())) + [18]
	num = 0
	for i in range(n):
		t = 10 ** int(a[i + 1] - a[i]) - 1
		if k > t:
			k -= t
			num += int(10 ** a[i]) * t
		else:
			num += int(10 ** a[i]) * k
			print('%d' % num)
			break


import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	k += 1
	ans = 0
	for i in range(n):
		if i != n - 1:
			use = min(k, 10 ** (a[i + 1] - a[i]) - 1)
		else:
			use = k
		ans += 10 ** a[i] * use
		k -= use
	ANS.append(str(ans))
print('\n'.join(ANS))


R = lambda : map(int, input().split())
(t,) = R()
while t:
	t -= 1
	(n, k) = R()
	a = (*R(), 18)
	s = i = 0
	while k >= 0:
		s += 10 ** a[i] * min((d := (10 ** (a[i + 1] - a[i]) - 1)), k + 1)
		k -= d
		i += 1
	print(s)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp_vars_int = lambda : map(int, input().split())
inp_list_int = lambda : list(map(int, input().split()))
import math
t = int(input())
for _ in range(t):
	(_, k) = inp_vars_int()
	a = inp_list_int()
	n = len(a)
	c = k + 1
	res = 0
	a.append(math.inf)
	for i in range(1, len(a)):
		diff = 10 ** a[i] - 10 ** a[i - 1]
		add = min(c * 10 ** a[i - 1], diff)
		res += add
		c -= diff // 10 ** a[i - 1]
		if c <= 0:
			break
	print(res)


def x(left, now, next_):
	if next_ == -1:
		return left
	return min(left, 10 ** (next_ - now) - 1)

def solve():
	(n, k) = map(int, input().split())
	k += 1
	notes = list(map(int, input().split()))
	notes.append(-1)
	val = 0
	for i in range(n):
		a = x(k, notes[i], notes[i + 1])
		val += a * 10 ** notes[i]
		k -= a
	return val
n = int(input())
for _ in range(n):
	print(solve())


import sys
inp = sys.stdin.readline

def solve():
	(n, k) = map(int, inp().split())
	a = list(map(int, inp().split()))
	c = [0] * n
	for i in range(n - 1):
		c[i] = 10 ** (a[i + 1] - a[i]) - 1
	c[n - 1] = 2000000000
	s = 0
	r = []
	for i in range(n):
		if s + c[i] > k:
			for j in range(i):
				v = str(c[j])
				r.append(v + '0' * (len(v) - a[j + 1] - a[j]))
			r.append(str(k + 1 - s))
			break
		s += c[i]
	r.reverse()
	print(''.join(r))

def main():
	for i in range(int(inp())):
		solve()
main()


t = int(input())
while t:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	burls = [int(x) for x in input().split()]
	cnt = 0
	ans = ''
	for i in range(1, len(burls)):
		temp_diff = burls[i] - burls[i - 1]
		cnt += 10 ** temp_diff - 1
		if cnt > k:
			cnt -= 10 ** temp_diff - 1
			break
		ans = '9' * temp_diff + ans
	ans = str(k - cnt + 1) + ans
	print(ans)


def solve(k, b, n):
	s = 0
	i = 0
	while k > 0:
		if i < n - 1:
			add = 10 ** (b[i + 1] - b[i]) - 1
			if add < k:
				s += add * 10 ** b[i]
				k -= add
			else:
				s += k * 10 ** b[i]
				k = 0
		else:
			s += k * 10 ** b[i]
			break
		i += 1
	return s
t = int(input())
for x in range(t):
	a = input().split()
	n = int(a[0])
	k = int(a[1])
	b = input().split()
	b = [int(_) for _ in b]
	print(solve(k + 1, b, n))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	j = 0
	i = 1
	fin = 0
	while j <= k:
		if i == len(a):
			fin += (k - j + 1) * pow(10, a[i - 1])
			break
		p = (pow(10, a[i]) - pow(10, a[i - 1])) // pow(10, a[i - 1])
		if p > k - j + 1:
			fin += (k - j + 1) * pow(10, a[i - 1])
			break
		else:
			fin += p * pow(10, a[i - 1])
			j += p
		i += 1
	print(fin)


from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
import os
import sys
from itertools import *
from io import BytesIO, IOBase
import math
import bisect
from math import inf
import random

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())
M = 1000000007

def main():
	t = 1
	t = int(input())
	for _ in range(1, t + 1):
		(n, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		arr.append(100)
		x = k + 1
		ans = 0
		for i in range(n):
			u = arr[i]
			v = arr[i + 1]
			if x >= 10 ** (v - u):
				ans += 10 ** u * (10 ** (v - u) - 1)
				x -= 10 ** (v - u) - 1
			else:
				ans += 10 ** u * x
				break
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def getint():
	return [int(i) for i in input().split()]

def get():
	return int(input())

def getstr():
	return [i for i in input().split()]

def S():
	for test in range(int(input())):
		solve()
import math
import itertools as it
import bisect
import time
import collections as ct

def solve():
	(n, k) = getint()
	ans = 0
	a = getint()
	b = []
	for i in a:
		b.append(10 ** i)
	t = 0
	for i in range(n - 1):
		l = (b[i + 1] - b[i]) // b[i]
		if t + l > k + 1:
			ans += b[i] * (k + 1 - t)
			t = k + 1
		else:
			t += l
			ans += b[i] * l
	print(ans + b[n - 1] * (k + 1 - t))
S()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	line = list(map(int, input().split()))
	(a, k) = (0, k + 1)
	for i in range(n - 1):
		t = line[i + 1] - line[i]
		minim = min(10 ** t - 1, k)
		a = a + 10 ** line[i] * minim
		k = k - minim
		if k == 0:
			break
	print(a + 10 ** line[-1] * k)


number_tests = int(input(''))
for test in range(number_tests):
	list_input = input('').split()
	number_types = int(list_input[0])
	amount = int(list_input[1]) + 1
	list_types = input('').split()
	result = 0
	count = 0
	for types in range(number_types):
		if count != 0:
			actual = 10 ** int(list_types[count])
			previous = 10 ** int(list_types[count - 1])
			diff = int(actual / previous) - 1
			if diff >= amount and amount > 0:
				result += amount * previous
				amount = 0
			elif amount > diff and amount > 0 and (types == number_types - 1):
				result += diff * previous
				amount -= diff
				result += amount * actual
			elif amount > diff and amount > 0:
				result += diff * previous
				amount -= diff
		count += 1
	if count == 1:
		print(amount)
	else:
		print(result)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k += 1
	arr = list(map(int, input().split()))
	ans = 0
	for i in range(len(arr)):
		arr[i] = 10 ** arr[i]
	canUse = [10 ** 20] * n
	for i in range(0, n - 1):
		canUse[i] = arr[i + 1] // arr[i] - 1
	for i in range(0, n - 1):
		useHere = min(canUse[i], k)
		k -= useHere
		ans += useHere * arr[i]
	if k > 0:
		ans += arr[n - 1] * k
	print(ans)


from collections import Counter
from sys import *
from collections import defaultdict as dd
from math import *

def inp():
	return int(stdin.readline())

def vinp():
	return map(int, stdin.readline().split())

def linp():
	return list(map(int, stdin.readline().split()))

def sinp(n=1):
	if n == 1:
		return stdin.readline()
	elif n == 2:
		return list(stdin.readline())
	else:
		return list(stdin.readline().split())

def pr(*x, end='\n'):
	print(*x, end=end)

def mod(f, val=1000000007):
	return f % val

def csort(c):
	sorted(c.items(), key=lambda pair: pair[1], reverse=True)

def indc(l, n):
	c = {}
	for i in range(n):
		c[l[i]] = c.get(l[i], []) + [i + 1]
	return c
cou = inp()
for _ in range(cou):
	(n, k) = vinp()
	l = linp()
	k += 1
	f = 0
	for i in range(n):
		if i == n - 1:
			f += k * 10 ** l[n - 1]
		else:
			x = 10 ** (l[i + 1] - l[i]) - 1
			f += 10 ** l[i] * min(x, k)
			k -= min(x, k)
	pr(f)


def count(n, a, k):
	ans = [0] * n
	for i in range(n - 1):
		max_fill = 10 ** (a[i + 1] - a[i]) - 1
		if k < max_fill:
			ans[i] = k + 1
			return ans
		ans[i] += max_fill
		k -= max_fill
	ans[n - 1] = k + 1
	return ans

def solve(n, a, k):
	c = count(n, a, k)
	return sum((10 ** a[i] * c[i] for i in range(n)))

def main():
	tests = int(input())
	ans = [None] * tests
	for t in range(tests):
		(n, k) = map(int, input().split())
		a = [*map(int, input().split())]
		ans[t] = solve(n, a, k)
	print(*ans, sep='\n')
main()


from math import log
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split(' ')))
	req = k + 1
	a = list(map(int, input().split(' ')))
	ptr1 = 0
	ptr2 = 1
	x = 0
	n = 0
	while ptr2 < len(a):
		x = int((pow(10, a[ptr2]) - pow(10, a[ptr1])) / pow(10, a[ptr1]))
		if req < x:
			n = n + req * pow(10, a[ptr1])
			req = 0
		else:
			req = req - x
			n = n + x * pow(10, a[ptr1])
		ptr1 += 1
		ptr2 += 1
	if len(a) == 1:
		print(req)
	elif req > 0:
		n += req * pow(10, a[len(a) - 1])
		print(n)
	else:
		print(n)


import sys, math
inf = sys.maxsize

def get_ints():
	return map(int, input().split())

def get_array():
	return list(map(int, input().split()))
mod = 1000000007
MOD = 998244353

def main():
	for _ in range(int(input())):
		(n, k) = get_ints()
		arr = get_array()
		k += 1
		ans = 0
		for i in range(n):
			if i == n - 1:
				ans += k * pow(10, arr[-1])
			elif k > 0:
				x = pow(10, arr[i + 1] - arr[i]) - 1
				ans += pow(10, arr[i]) * min(x, k)
				k -= min(x, k)
		print(ans.__int__())
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for T in range(int(input())):
	mp = [0] * 1005
	(n, k) = map(int, input().split())
	k += 1
	(res, pre) = (0, 0)
	a = list(map(int, input().split()))
	for i in a:
		mp[i] = 1
	i = 0
	while True:
		if k <= 0:
			break
		if mp[i] == 1:
			if k - 9 >= 0:
				k -= 9
				res += 9 * pow(10, i)
				pre = i
			else:
				res += k * pow(10, i)
				break
		elif k - 9 * pow(10, i - pre) >= 0:
			k -= 9 * pow(10, i - pre)
			res += 9 * pow(10, i)
		else:
			res += k * pow(10, pre)
			break
		i += 1
	print(res)


import sys
import math
inpu = sys.stdin.readline
prin = sys.stdout.write
t = int(inpu())
for _ in range(t):
	(n, k) = map(int, inpu().split())
	a = list(map(int, inpu().split()))
	bigs = [10 ** (a[i + 1] - a[i]) - 1 for i in range(n - 1)]
	needed = k + 1
	used = [0] * n
	i = 0
	while needed >= 0:
		if i == n - 1:
			used[-1] = needed
			break
		elif bigs[i] <= needed:
			used[i] = bigs[i]
			needed -= bigs[i]
		else:
			used[i] = needed
			break
		i += 1
	tot = 0
	for i in range(n):
		tot += used[i] * 10 ** a[i]
	print(tot)


t = int(input())
for test_case in range(t):
	(n, k) = map(int, input().split())
	a = [10 ** int(i) for i in input().split()]
	s = 0
	for i in range(n):
		v_to_add = a[i + 1] - a[i] if i < n - 1 else a[i] * (k + 1)
		s += v_to_add
		k -= int(v_to_add / a[i])
		if k <= -1:
			s += a[i] * (k + 1)
			break
	print(s)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	mini = 0
	counter = 0
	for g in range(n):
		if g + 1 != n and k + 1 - counter >= 10 ** s[g + 1] // 10 ** s[g] - 1:
			counter += 10 ** s[g + 1] // 10 ** s[g] - 1
			mini += (10 ** s[g + 1] // 10 ** s[g] - 1) * 10 ** s[g]
		else:
			mini += 10 ** s[g] * (k + 1 - counter)
			break
	print(mini)


import sys, math
input = sys.stdin.readline
INF = int(1000000000.0) + 7

def solve():
	(n, k) = map(int, input().split())
	data = list(map(int, input().split()))
	cur = 0
	ans = 0
	for i in range(n - 1):
		now = 10 ** (data[i + 1] - data[i]) - 1
		if cur + now <= k:
			ans += 10 ** data[i] * now
			cur += now
		else:
			ans += 10 ** data[i] * (k + 1 - cur)
			cur = k + 1
			break
	if cur == k + 1:
		print(ans)
		return
	else:
		print(ans + (k + 1 - cur) * 10 ** data[-1])
t = int(input())
while t:
	t -= 1
	solve()


import math

def solve():
	(n, k) = list(map(int, input().split()))
	denominations = list(map(int, input().split()))
	(ans, remainder) = (0, k + 1)
	max_occurances = []
	for i in range(len(denominations) - 1):
		occ = 10 ** denominations[i + 1] // 10 ** denominations[i] - 1
		max_occurances.append(occ)
	for (idx, occurance) in enumerate(max_occurances):
		if remainder == 0:
			break
		power = 10 ** denominations[idx]
		useable = min(occurance, remainder)
		remainder -= useable
		ans += useable * power
	if remainder > 0:
		d = denominations[-1]
		ans += remainder * 10 ** d
	return ans
for i in range(int(input())):
	print(solve())


for tc in range(int(input())):
	(n, k) = [int(xx) for xx in input().split()]
	a = sorted([int(xx) for xx in input().split()])
	ans = 0
	balance = k + 1
	for i in range(1, n):
		cur = a[i - 1]
		nxt = None
		nxt = a[i]
		diff = nxt - cur
		max_pos = 10 ** diff - 1
		if max_pos < balance:
			balance -= max_pos
			ans += 10 ** cur * max_pos
		else:
			ans += 10 ** cur * balance
			balance = 0
	print(ans + 10 ** a[-1] * balance)


import sys
import io, os
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = [10 ** a for a in A]
	cur_max = B[0] * k
	for i in range(1, n):
		a = A[i]
		b = B[i]
		y = B[i] - 1
		cnt = 0
		for j in reversed(range(i)):
			(q, r) = divmod(y, B[j])
			cnt += q
			y = r
		if cnt > k:
			ans = cur_max + 1
			break
		else:
			cur_max = (k - cnt + 1) * B[i] + B[i] - 2
	else:
		print(cur_max + 1)
		continue
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter, defaultdict
import math
import heapq
import bisect

def nck(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - i + 1) // i
	return res
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ls = [0] * n
	for i in range(n - 1):
		ls[i] = 10 ** arr[i + 1] // 10 ** arr[i] - 1
	a = 0
	f = 0
	vv = -1
	for i in range(n - 1):
		if k >= ls[i]:
			a += ls[i] * 10 ** arr[i]
			k -= ls[i]
		else:
			a += (k + 1) * 10 ** arr[i]
			k = 0
			f = 1
			break
	if k > 0 or f == 0:
		a += (k + 1) * 10 ** arr[-1]
	print(a)


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	deno = [10 ** int(x) for x in input().split()]
	arr = [0] * n
	arr[0] = k + 1
	for i in range(n - 1):
		if arr[i] >= deno[i + 1] // deno[i]:
			tmp = arr[i]
			arr[i] = deno[i + 1] // deno[i] - 1
			arr[i + 1] = tmp - arr[i]
	ans = 0
	for i in range(n):
		ans += arr[i] * deno[i]
	print(ans)


from sys import stdin
import math
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = list(map(int, input().split()))
	kk = k + 1
	ans = 0
	for i in range(len(d) - 1):
		s = pow(10, d[i])
		c = pow(10, d[i + 1] - d[i]) - 1
		ans += min(c, kk) * s
		kk -= min(c, kk)
	ans += kk * pow(10, d[-1])
	print(ans)


tt = int(input())
while tt > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	num = []
	for i in range(n):
		if i == n - 1:
			num.append(k + 1)
		else:
			nxt = a[i + 1] - a[i]
			number = pow(10, nxt) - 1
			if number <= k:
				num.append(number)
				k -= number
			else:
				num.append(k + 1)
				break
	itog = 0
	num.reverse()
	for i in num:
		add = 0
		for j in range(len(str(i))):
			itog *= 10
		itog += i
	print(itog)
	tt -= 1


import sys
input = sys.stdin.readline

def printL(list):
	sys.stdout.write(' '.join(map(str, list)) + '\n')

def printN(n):
	sys.stdout.write(str(n) + '\n')

def f(s, a, n):
	m = s
	ans = 0
	for i in range(n - 1, -1, -1):
		ans += m // a[i]
		m -= a[i] * (m // a[i])
	return ans
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	lft = k + 1
	m = 0
	for i in range(0, n - 1):
		m += pow(10, a[i]) * min(lft, pow(10, a[i + 1] - a[i]) - 1)
		lft -= min(lft, pow(10, a[i + 1] - a[i]) - 1)
		if lft <= 0:
			break
	if lft > 0:
		m += pow(10, a[n - 1]) * lft
	printN(m)


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	k += 1
	ans = 0
	for i in range(n - 1):
		if k > 0:
			temp = arr[i + 1] - arr[i]
			pow_10 = 10 ** temp
			pow_10 -= 1
			ans += 10 ** arr[i] * min(pow_10, k)
			k -= min(k, pow_10)
	if k > 0:
		ans += 10 ** arr[-1] * k
	print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, functools, copy, statistics
inf = float('inf')
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def LS():
	return input().split()
import time
t = I()
for _ in range(t):
	(n, k) = LI()
	list1 = LI()
	m = k + 1
	ans = 0
	if n == 1:
		ans = m
	else:
		for i in range(n - 1):
			a = m * 10 ** list1[i]
			if a < 10 ** list1[i + 1]:
				ans = ans + a
				break
			else:
				ans = ans + (10 ** (list1[i + 1] - list1[i]) - 1) * 10 ** list1[i]
				m = m - (10 ** (list1[i + 1] - list1[i]) - 1)
			if i + 1 == n - 1:
				ans = ans + m * 10 ** list1[i + 1]
				break
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	k += 1
	a = list(map(int, input().split()))
	v = 0
	a = sorted(a)
	for i in range(n - 1):
		A = 10 ** (a[i + 1] - a[i])
		n = min(k, A - 1)
		k -= n
		v += n * 10 ** a[i]
	A = 10 ** a[-1]
	v += k * 10 ** a[-1]
	print(v)


def banknotes(n, k, a):
	k += 1
	amount = 0
	a += [20]
	for i in range(n):
		max_notes = 10 ** (a[i + 1] - a[i]) - 1
		taken_notes = min(max_notes, k)
		k -= taken_notes
		amount += taken_notes * 10 ** a[i]
	return amount
for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	print(banknotes(n, k, a))


import sys
ntests = int(sys.stdin.readline())
for _ in range(ntests):
	inval = sys.stdin.readline().strip()
	(ncurr, maxnotes) = inval.split()
	maxnotes = int(maxnotes)
	ncurr = int(ncurr)
	curr = [int(x) for x in sys.stdin.readline().strip().split()]
	curr += [1000]
	maxnotes += 1
	ans = 0
	curridx = 0
	while maxnotes:
		nnotes = min(maxnotes, 10 ** (curr[curridx + 1] - curr[curridx]) - 1)
		maxnotes -= nnotes
		ans += nnotes * 10 ** curr[curridx]
		curridx += 1
	print(ans)


t = int(input())
for T in range(t):
	(n, k) = map(int, input().split())
	arr = input().split()
	arr = [10 ** int(x) for x in arr]
	k += 1
	ans = 0
	for i in range(n - 1):
		if k <= arr[i + 1] // arr[i] - 1:
			ans += arr[i] * k
			k = 0
			break
		else:
			ans += (arr[i + 1] // arr[i] - 1) * arr[i]
			k -= arr[i + 1] // arr[i] - 1
	print(int(ans + arr[n - 1] * k))


import sys
readline = sys.stdin.readline
T = int(readline())
for _ in range(T):
	(N, K) = map(int, readline().split())
	K += 1
	A = [pow(10, a) for a in map(int, readline().split())][::-1]
	ans = 0
	while K:
		a0 = A.pop()
		if A:
			a1 = A[-1]
			ans += min(a1 // a0 - 1, K) * a0
			K -= min(a1 // a0 - 1, K)
		else:
			ans += K * a0
			K = 0
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	sm = 0
	k += 1
	for i in range(n - 1):
		diff = a[i + 1] - a[i]
		temp = min(pow(10, diff) - 1, k)
		k -= temp
		ans += pow(10, a[i]) * temp
		if k == 0:
			break
	if k != 0:
		ans += pow(10, a[-1]) * k
	print(ans)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	c = []
	for i in a:
		c.append(10 ** i)
	if c[0] > 1:
		print(1)
		continue
	j = 0
	mn = 0
	while k > 0:
		if j == len(c) - 1:
			break
		if j + 1 < len(c) and (c[j + 1] - c[j]) // c[j] <= k:
			k -= (c[j + 1] - c[j]) // c[j]
			mn += c[j + 1] - c[j]
			j += 1
			if k == 0:
				mn += c[j]
		else:
			mn += (k + 1) * c[j]
			k = 0
	if k > 0:
		mn += (k + 1) * c[j]
	print(mn)


import sys
import math
testcase = int(input())
for test in range(0, testcase):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	slot = k
	res = 0
	check = False
	for i in range(0, n - 1):
		limit = 10 ** a[i + 1] // 10 ** a[i] - 1
		if slot >= limit:
			slot -= limit
			res += 10 ** a[i] * limit
		else:
			res += 10 ** a[i] * (slot + 1)
			check = True
			break
	if check == False:
		res += 10 ** a[-1] * (slot + 1)
	print(res)


import math
from collections import OrderedDict
from collections import Counter
from itertools import combinations

def solve(a, t):
	d = 0
	l = 0
	for i in range(len(a) - 1):
		f = a[i + 1] - a[i]
		if t > 0:
			b = int(math.pow(10, f)) - 1
			d += int(math.pow(10, a[i])) * min(b, t)
			t -= min(b, t)
	return d + t * int(math.pow(10, a[-1]))
t = int(input(''))
for i in range(t):
	(n, t) = list(map(int, input('').strip().split()))[:2]
	a = list(map(int, input('').strip().split()))[:n]
	print(solve(a, t + 1))


t = int(input())
for q in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = [10 ** int(x) for x in input().split()]
	lis = [arr[i + 1] / arr[i] - 1 for i in range(n - 1)]
	k += 1
	count = 0
	ans = 0
	i = 0
	while count < k and i < n - 1:
		if count + lis[i] <= k:
			ans += lis[i] * arr[i]
			count += lis[i]
			i += 1
		else:
			diff = k - count
			ans += diff * arr[i]
			count += diff
	if count == k:
		print(int(ans))
	else:
		print(int(ans) + int((k - count) * arr[i]))


import math as m

def L():
	return list(map(int, input().split()))

def I():
	return int(input())

def solve():
	(n, k) = map(int, input().split())
	arr = L()
	k += 1
	ans = 0
	for i in range(n - 1):
		if k > 0:
			x = 10 ** (arr[i + 1] - arr[i]) - 1
			okok = min(x, k)
			ans += 10 ** arr[i] * okok
			k -= okok
	ans += k * 10 ** arr[n - 1]
	print(ans)
for _ in range(int(input())):
	solve()


def banknotes(n, k, a):
	amount = 0
	for i in range(n):
		max_num = a[i + 1] // a[i] - 1
		if k > max_num:
			k -= max_num
			amount = amount + a[i] * max_num
		else:
			amount = amount + a[i] * k
			k = 0
	return amount
t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = input().split(' ')
	a = [10 ** int(ai) for ai in a]
	a.append(10 ** 18)
	print(banknotes(n, k + 1, a))


def solve():
	t = int(input())
	for _ in range(t):
		(n, k) = [int(s) for s in input().split()]
		a = [int(s) for s in input().split()]
		rep = True
		max_pow = 1
		for i in range(1, n):
			new_pow = 10 ** (a[i] - a[i - 1])
			if rep:
				if new_pow <= k + 1:
					k -= new_pow - 1
					max_pow *= new_pow
				else:
					rep = False
		print((k + 2) * max_pow - 1)
solve()


t = int(input())
ten = [10 ** i for i in range(12)]
for _ in range(t):
	(n, m) = map(int, input().split())
	x = [int(i) for i in input().split()]
	x.append(11)
	res = 0
	suma = 0
	for i in range(len(x) - 1):
		aux = ten[x[i + 1]] // ten[x[i]] - 1
		if res + aux > m:
			suma += ten[x[i]] * (m - res + 1)
			res += aux
			break
		suma += aux * ten[x[i]]
		res += aux
	if res <= m:
		suma += ten[x[n - 1]] * (m - res + 1)
	print(suma)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	ans = 0
	cont = 0
	for ind in range(len(arr)):
		arr[ind] = 10 ** arr[ind]
	for i in range(1, n):
		dif = arr[i] - arr[i - 1]
		if cont + arr[i] / arr[i - 1] - 1 <= k:
			cont += int(arr[i] / arr[i - 1] - 1)
			ans += arr[i] - arr[i - 1]
		else:
			ans += arr[i - 1] * (k - cont + 1)
			cont = k + 1
			break
	if cont == k + 1:
		print(int(ans))
	else:
		print(ans + (k + 1 - cont) * arr[n - 1])


for nt in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	a = 0
	k = k + 1
	for i in range(n - 1):
		if k > 0:
			x = 10 ** (l[i + 1] - l[i])
			x -= 1
			y = min(x, k)
			k -= y
			a += 10 ** l[i] * y
	a += k * 10 ** l[n - 1]
	print(a)


import sys
import os.path
from collections import *
import math
import bisect
import heapq as hq
from fractions import Fraction
from random import randint
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
input = sys.stdin.readline

def solve():
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	n += 1
	k += 1
	arr.append(20)
	brr = [0] * n
	for i in range(n):
		brr[i] = 10 ** arr[i]
	res = 0
	for i in range(n - 1):
		if brr[i] * k < brr[i + 1]:
			res += brr[i] * k
			break
		k -= (brr[i + 1] - brr[i]) // 10 ** arr[i]
		res += brr[i + 1] - brr[i]
	print(res)
t = int(input())
while t:
	t -= 1
	solve()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if n == 1:
		print(k + 1)
		continue
	prev = 0
	cur = 0
	k += 1
	for i in range(1, n):
		if 10 ** arr[i] // 10 ** arr[i - 1] - 1 >= k:
			cur = cur + 10 ** arr[i - 1] * k
			k = 0
			break
		else:
			prev = 10 ** arr[i] // 10 ** arr[i - 1] - 1
			k -= prev
			cur = cur + 10 ** arr[i - 1] * prev
	if k:
		cur = cur + 10 ** arr[-1] * k
	print(cur)


def solve():
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	val = 0
	for i in range(n):
		if i == n - 1:
			val += k * 10 ** a[i]
			break
		diff = 10 ** (a[i + 1] - a[i])
		if k < diff - 1:
			val += k * 10 ** a[i]
			break
		if i == 0:
			k -= diff - 2
			val += diff - 2
		else:
			k -= diff - 1
			val += (diff - 1) * 10 ** a[i]
	print(val + 1)
t = int(input())
for i in range(t):
	solve()


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve(n, k, A):
	ret = 0
	remK = k + 1
	for i in range(n - 1):
		t = min(10 ** (A[i + 1] - A[i]) - 1, remK)
		remK -= t
		assert remK >= 0
		ret += t * 10 ** A[i]
		if remK == 0:
			return ret
	ret += remK * 10 ** A[-1]
	return ret
TC = int(input())
for tc in range(TC):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	res = solve(n, k, A)
	print(res)


t = int(input())
ans = []
while t > 0:
	number = 0
	t -= 1
	(n, k) = [int(i) for i in input().split()]
	s = [10 ** int(i) for i in input().split()]
	for i in range(1, n):
		if s[i] // s[i - 1] > k:
			if s[i] // s[i - 1] - 1 == k:
				number = number + k * s[i - 1] + s[i]
				k = 0
				break
			else:
				number += (k + 1) * s[i - 1]
				k = 0
				break
		else:
			number += (s[i] // s[i - 1] - 1) * s[i - 1]
			k -= s[i] // s[i - 1] - 1
	if k != 0:
		number += (k + 1) * s[-1]
	ans.append(number)
for i in ans:
	print(i)


import sys

def rall():
	return sys.stdin.readlines()

def rl():
	return sys.stdin.readline().strip()

def rl_types(types):
	str_list = [x for x in sys.stdin.readline().strip().split(' ')]
	return [types[i](str_list[i]) for i in range(len(str_list))]

def pr(something=''):
	sys.stdout.write(str(something) + '\n')

def pra(array):
	sys.stdout.write(' '.join([str(x) for x in array]) + '\n')

def solve(array):
	return array
NT = int(rl())
for ti in range(NT):
	(n, k) = map(int, rl().split(' '))
	notes = list(map(int, rl().split(' ')))
	kover = k + 1
	max_per_note = [0] * len(notes)
	for i in range(len(notes) - 1):
		max_per_note[i] = int('9' * (notes[i + 1] - notes[i]))
	tot = 0
	for i in range(len(notes) - 1):
		note_val = 10 ** notes[i]
		tot += note_val * min(kover, max_per_note[i])
		kover = max(0, kover - max_per_note[i])
		if kover == 0:
			break
	if kover > 0:
		note_val = 10 ** notes[-1]
		tot += note_val * kover
	pr(tot)


t = int(input())
for e in range(t):
	l1 = list(map(int, input().split()))
	l22 = list(map(int, input().split()))
	l2 = []
	for i in range(len(l22)):
		l2.append(10 ** l22[i])
	q = l1[1]
	s = 0
	chk = 0
	for i in range(len(l2) - 1):
		if l2[i] * (q + 1) < l2[i + 1]:
			s += l2[i] * (q + 1)
			q = 0
			break
		else:
			q1 = int(l2[i + 1] / l2[i]) - 1
			s += l2[i] * q1
			q = q - q1
			if q == 0:
				if i == len(l2) - 2:
					chk = 1
	if q != 0:
		s += (q + 1) * l2[-1]
	if q == 0 and chk == 1:
		s += l2[-1]
	print(s)


import math
import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	answer = ''
	(n, k) = map(int, input().split())
	k += 1
	data = list(map(int, input().split()))
	li = []
	for i in range(1, n):
		li.append(data[i] - data[i - 1])
	for t in li:
		temp = pow(10, t) - 1
		if k >= temp:
			k -= temp
			answer = str(temp) + answer
		else:
			answer = str(k) + answer
			k = 0
		if k == 0:
			break
	if k > 0:
		answer = str(k) + answer
	print(answer)


R = lambda : map(int, input().split())
(t,) = R()
while t:
	t -= 1
	(n, k) = R()
	a = (*R(), 18)
	s = 0
	for (x, y) in zip(a, a[1:]):
		s += 10 ** x * max(0, min((d := (10 ** (y - x) - 1)), k + 1))
		k -= d
	print(s)


def power(base, power):
	result = 1
	while power > 0:
		if power % 2 == 0:
			power = power // 2
			base = base * base
		else:
			power = power - 1
			result = result * base
			power = power // 2
			base = base * base
	return result
ans = []
n = int(input())
for i in range(n):
	t = list(input().split())
	(n, k) = (int(t[0]), int(t[1]))
	t = list(input().split())
	(m, fl, p) = (0, 0, 0)
	t = [power(10, int(i)) for i in t]
	for j in range(len(t) - 1):
		x = t[j + 1] // t[j] - 1
		p += x
		m = m + x * t[j]
		if p > k:
			fl = j + 1
			p -= x
			m -= x * t[j]
			break
	if fl == 0:
		m += (k - p + 1) * t[len(t) - 1]
	else:
		m += (k - p + 1) * t[fl - 1]
	print(m)


t = int(input())
b = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000]
for i in range(t):
	s = input().split(' ')
	n = int(s[0])
	k = int(s[1])
	k = k + 1
	s = input().split(' ')
	ans = 0
	for i in range(len(s) - 1):
		cnt = b[int(s[i + 1])] // b[int(s[i])] - 1
		if k >= cnt:
			ans = ans + b[int(s[i])] * cnt
			k = k - cnt
		else:
			ans = ans + b[int(s[i])] * k
			k = 0
			break
	if k > 0:
		ans = ans + b[int(s[len(s) - 1])] * k
	print(ans)


def fun():
	t = int(input())
	for i in range(t):
		(k, n) = map(int, input().split())
		arr = list(map(int, input().split()))
		for i in range(len(arr)):
			arr[i] = 10 ** arr[i]
		mn = prev = 0
		done = False
		for i in range(1, len(arr)):
			prev = mn
			mn += (arr[i] - arr[i - 1]) // arr[i - 1]
			if mn > n:
				extra = n - prev
				print((extra + 1) * arr[i - 1] + arr[i - 1] - 1)
				done = True
				break
		if not done:
			print((n - mn) * arr[-1] + arr[-1] + arr[-1] - 1)
fun()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	ans = 0
	k += 1
	for i in range(n - 1):
		a = s[i + 1] - s[i]
		b = min(10 ** a - 1, k)
		ans += 10 ** s[i] * b
		k -= b
		if k == 0:
			break
	ans += 10 ** s[-1] * k
	print(ans)


import sys

def get_ans(n, banknotes, denominations):
	banknotes += 1
	ans = 0
	for i in range(n - 1):
		can_use = ten_powers[denominations[i + 1] - denominations[i]] - 1
		notes_using = min(banknotes, can_use)
		banknotes -= notes_using
		ans += ten_powers[denominations[i]] * notes_using
		if banknotes == 0:
			break
	if banknotes > 0:
		ans += ten_powers[denominations[n - 1]] * banknotes
	return ans
input = lambda : sys.stdin.readline().rstrip('\r\n')
ten_powers = [1 for i in range(10)]
temp = 1
for i in range(1, 10):
	temp = temp * 10
	ten_powers[i] = temp
t = int(input())
for i in range(t):
	(n, banknotes) = input().split()
	(n, banknotes) = (int(n), int(banknotes))
	denominations = map(int, input().split())
	denominations = sorted(denominations)
	print(get_ans(n, banknotes, denominations))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(lambda x: 10 ** int(x), input().split()))
	index = 0
	tot = 0
	k += 1
	while k != 0:
		if index != n - 1:
			diff = (l[index + 1] - l[index]) // l[index]
			mini = min(diff, k)
			k -= mini
			tot += l[index] * mini
			index += 1
		else:
			tot += l[index] * k
			break
	print(tot)


def solve():
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	d = [0 for i in range(n)]
	for i in range(n - 1):
		curr = arr[i + 1] - arr[i]
		for j in range(curr):
			d[i] = d[i] * 10 + 9
	(s, x) = (0, 0)
	for i in range(n - 1):
		s += d[i]
		if s > k:
			s -= d[i]
			print(k - s + 1, end='')
			if x > 0:
				print(x, end='')
			print()
			return
		delta = 1
		while delta < x:
			delta *= 10
		x += d[i] * delta
	k -= s - 1
	print(k, end='')
	if x > 0:
		print(x, end='')
	print()
for _ in range(int(input())):
	solve()


for __ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(lambda x: 10 ** int(x), input().split()))
	kneed = [0]
	for i in range(1, n):
		kneed.append(kneed[-1] + (a[i] - a[i - 1]) // a[i - 1])
	gt = 0
	while gt < n and kneed[gt] <= k:
		gt += 1
	ans = 0
	if gt == n:
		gt -= 1
		ans += (k - kneed[gt] + 1) * a[-1]
		k = kneed[gt] - 1
	ans += a[gt - 1] - 1
	k -= kneed[gt - 1]
	ans += (k + 1) * a[gt - 1]
	print(ans)


for fghn in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	note = 0
	value = 0
	for i in range(1, n):
		if note + 10 ** a[i] / 10 ** a[i - 1] - 1 > k:
			print(int(value) + int((k - note + 1) * 10 ** a[i - 1]))
			break
		note += 10 ** a[i] / 10 ** a[i - 1] - 1
		value += (10 ** a[i] / 10 ** a[i - 1] - 1) * 10 ** a[i - 1]
	else:
		print(int(value) + int(k - note + 1) * 10 ** a[-1])


mod = 1000000007
t = int(input())
p = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]
while t:
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a = [p[x] for x in a]
	k += 1
	ans = 0
	for i in range(n - 1):
		s = a[i + 1] // a[i] - 1
		if k >= s:
			ans += s * a[i]
			k -= s
		else:
			ans += k * a[i]
			k = 0
			break
	ans += a[-1] * k
	print(ans)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	sum = 0
	ind = 0
	for i in range(1, n):
		temp = 10 ** a[i] // 10 ** a[i - 1] - 1
		if k - temp >= 0:
			sum += temp * 10 ** a[i - 1]
			k -= temp
			ind = i
		else:
			break
	if k > 0:
		sum += (k + 1) * 10 ** a[ind]
	elif k == 0:
		sum += 10 ** a[min(ind, n - 1)]
	print(sum)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split(' ')))
	ls = list(map(int, input().split(' ')))
	p10s = [10 ** i for i in ls]
	ans = 0
	used = 0
	kk = k
	last = 1
	for (i, j) in zip(p10s, p10s[1:]):
		if kk * i == j - 1:
			ans += j + (kk - 1) * i
			kk = 0
			break
		if kk * i >= j:
			ans += j - 1 - (i - 1) - (1 if i == 1 else 0)
			used += j // i - 1 - (1 if i == 1 else 0)
			kk = k - used
			last = j
		else:
			ans += kk * i
			kk = 0
			break
	if kk > 0:
		ans += kk * last
	print(ans + 1)


def solve():
	(n, coins) = list(map(int, input().split()))
	denominations = list(map(int, input().split()))
	number = 0
	coins += 1
	denominations.sort()
	for i in range(n):
		if i == n - 1:
			value = coins
		else:
			leverage = 10 ** abs(denominations[i] - denominations[i + 1]) - 1
			value = min(leverage, coins)
		number += 10 ** denominations[i] * value
		coins -= value
	return number
for _ in range(int(input())):
	print(solve())


def bp(a, n):
	if n == 0:
		return 1
	if n & 1:
		return a * bp(a, n - 1)
	half = bp(a, n // 2)
	return half * half
t = int(input())
while t > 0:
	f = input().split(' ')
	(n, k) = f
	n = int(n)
	k = int(k)
	ar = input().split(' ')
	ans = 0
	left = k + 1
	for i in range(n):
		add = left
		if i + 1 < n:
			add = min(add, bp(10, int(ar[i + 1]) - int(ar[i])) - 1)
		ans += add * bp(10, int(ar[i]))
		left -= add
	print(ans)
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	k += 1
	ans = 0
	for i in range(n):
		if i == n - 1:
			ans += k * 10 ** arr[i]
			break
		elif 10 ** (arr[i + 1] - arr[i]) - 1 >= k:
			ans += k * 10 ** arr[i]
			break
		else:
			k -= 10 ** (arr[i + 1] - arr[i]) - 1
			ans += (10 ** (arr[i + 1] - arr[i]) - 1) * 10 ** arr[i]
	print(ans)


import sys, os, io
import math
from collections import defaultdict

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	(n, k) = li()
	a = li()
	x = []
	k += 1
	a.sort()
	for i in range(1, n):
		x.append(a[i] - a[i - 1])
	ans = 0
	notes = 0
	for i in range(len(x)):
		if k > 0:
			ans += 10 ** a[i] * min(10 ** x[i] - 1, k)
			k -= min(10 ** x[i] - 1, k)
	print(ans + k * 10 ** a[-1])
t = 1
t = ii()
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().strip().split()))
	A = list(map(int, input().strip().split()))
	B = []
	total = 0
	for i in range(len(A) - 1):
		diff = A[i + 1] - A[i]
		if i == 0:
			if 10 ** diff - 2 < k - total:
				B.append(10 ** diff - 2)
				total += 10 ** diff - 2
			else:
				B.append(k - total)
				total += k - total
				break
		elif total + 10 ** diff - 1 < k:
			B.append(10 ** diff - 1)
			total += 10 ** diff - 1
		else:
			B.append(k - total)
			total += k - total
			break
	if total - k != 0:
		B.append(k - total)
	ans = 0
	for i in range(len(B)):
		ans += B[i] * 10 ** A[i]
	print(ans + 1)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
mod = int(1000000000.0) + 7

def power(k, n):
	if n == 0:
		return 1
	if n % 2:
		return power(k, n - 1) * k % mod
	t = power(k, n // 2)
	return t * t % mod

def totalPrimeFactors(n):
	count = 0
	if n % 2 == 0:
		count += 1
		while n % 2 == 0:
			n //= 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			count += 1
			while n % i == 0:
				n //= i
		i += 2
	if n > 2:
		count += 1
	return count

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		k += 1
		a = list(map(int, input().split()))
		for i in range(n):
			a[i] = 10 ** a[i]
		ans = 0
		m = [1]
		z = '9'
		for i in range(15):
			m.append(int(z))
			z += '9'
		for i in range(1, n):
			if k * a[i - 1] < a[i]:
				ans += k * a[i - 1]
				k = 0
				break
			for j in range(len(m)):
				if m[j] * a[i - 1] > a[i] or k < m[j]:
					ans += m[j - 1] * a[i - 1]
					k -= m[j - 1]
					break
		ans += k * a[-1]
		print(ans)
	return
main()


def f(s, A):
	i = len(A) - 1
	answer = 0
	while s > 0:
		s2 = s // 10 ** A[i]
		answer += s2
		s -= s2 * 10 ** A[i]
		i -= 1
	return answer

def process(k, A):
	answer = float('inf')
	k += 1
	i = len(A) - 1
	while True:
		x1 = f(10 ** A[i] - 1, A[:i])
		if x1 < k:
			entry = (k - x1) * 10 ** A[i] + 10 ** A[i] - 1
			return entry
		i -= 1
	return answer
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	print(process(k, A))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = []
	for i in range(n):
		u = int('9' * (a[i + 1] - a[i])) if i < n - 1 else 9
		if u <= k:
			b.append(u)
			k -= u
		else:
			b.append(k)
			k = 0
			break
	ans = 0
	for i in range(len(b)):
		ans += b[i] * 10 ** a[i]
	ans += 10 ** a[len(b) - 1]
	if k != 0:
		ans += k * 10 ** a[len(b) - 1]
	print(ans)


import sys
from bisect import bisect_left as lb
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue as pq
from math import gcd
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
lii = lambda : list(map(int, list(ip())))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
mod1 = 998244353
for _ in range(ii()):
	(n, k) = il()
	a = il()
	if n == 1:
		print((k + 1) * 10 ** a[0])
		continue
	k += 1
	ans = 0
	for i in range(n - 1):
		t = 10 ** (a[i + 1] - a[i]) - 1
		x = min(t, k)
		k -= x
		ans += 10 ** a[i] * x
		if k == 0:
			break
	if k > 0:
		ans += k * 10 ** a[n - 1]
	print(ans)


def ans(n, k, l):
	res = 0
	if n == 1 or k < 9:
		return k + 1
	k += 1
	for i in range(len(l) - 1):
		if k > 0:
			x = pow(10, l[i + 1] - l[i]) - 1
			y = min(x, k)
			res += y * 10 ** l[i]
			k -= y
		else:
			break
	if k > 0:
		y = k
		res += y * 10 ** l[-1]
	return res
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	print(ans(n, k, l))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k += 1
	ans = 0
	arr = list(map(int, input().split()))
	for i in range(n - 1):
		if k > 0:
			x = 10 ** (arr[i + 1] - arr[i]) - 1
			val = min(x, k)
			ans += 10 ** arr[i] * val
			k -= val
	ans += k * 10 ** arr[n - 1]
	print(ans)


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		temp = []
		sm = 0
		k += 1
		for i in range(1, n):
			temp.append(pow(10, arr[i] - arr[i - 1]) - 1)
			sm += temp[-1]
			if sm >= k:
				break
		ans = 0
		idx = 0
		while k and idx < len(temp):
			if k >= temp[idx]:
				k -= temp[idx]
				ans += temp[idx] * pow(10, arr[idx])
			else:
				ans += k * pow(10, arr[idx])
				k = 0
			idx += 1
		if k:
			ans += k * pow(10, arr[idx])
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	k += 1
	a = [int(i) for i in input().split()]
	ans = ''
	for i in range(n - 1):
		p = a[i + 1] - a[i]
		if k < 10 ** p:
			ans = str(k) + ans
			k = 0
			break
		else:
			s = '9' * p
			ans = s + ans
			k -= int(s)
	ans = str(k) + ans
	print(int(ans))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	notes = [10 ** x for x in a]
	s = 0
	save = 0
	last = False
	for i in range(len(a)):
		if i == len(a) - 1:
			temp = k
			last = True
		else:
			temp = min(k, notes[i + 1] // notes[i] - 1)
		s += temp * notes[i]
		k -= temp
		save = i
		if k == 0:
			break
	if last:
		print(s + notes[-1])
		continue
	if temp < notes[save + 1] // notes[save] - 1:
		s += notes[save]
	else:
		s += notes[save + 1]
	print(s)


def solve(n, k, array):
	ans = 0
	current_ten = 0
	next_ten = 0
	i = 0
	remaining_k = k + 1
	while i < n - 1:
		if remaining_k <= 0:
			break
		diff = pow(10, array[i + 1] - array[i]) - 1
		if remaining_k - diff >= 0:
			ans += pow(10, array[i]) * diff
		else:
			ans += pow(10, array[i]) * remaining_k
		remaining_k = max(0, remaining_k - diff)
		i += 1
	ans += pow(10, array[i]) * remaining_k
	return ans
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	array = [int(x) for x in input().split()]
	print(solve(n, k, array))


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	k += 1
	ans = 0
	A = [pow(10, a) for a in map(int, input().split())]
	for i in range(n):
		cnt = k
		if i + 1 < n:
			cnt = min(cnt, A[i + 1] // A[i] - 1)
		ans += cnt * A[i]
		k -= cnt
	print(ans)


def solve(test_num: int) -> None:
	(n, k) = [int(a) for a in input().split(' ')]
	banknotes = [10 ** int(a) for a in input().split(' ')]
	k += 1
	index = 0
	money = 0
	while k > 0:
		if n - 1 > index:
			limit = banknotes[index + 1] // banknotes[index] - 1
		else:
			limit = k
		if k > limit:
			money += banknotes[index] * limit
			k -= limit
		else:
			money += banknotes[index] * k
			k = 0
		index += 1
	print(money)
test_num: int = int(input())
for i in range(1, test_num + 1):
	solve(i)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k += 1
	a = list(map(int, input().split()))
	coins = []
	for i in range(n):
		coins.append(10 ** a[i])
	tmp = []
	s = 0
	for i in range(n - 1):
		dif = int(round(coins[i + 1] / coins[i])) - 1
		if dif < k:
			k -= dif
			s += coins[i] * dif
		else:
			s += coins[i] * k
			k = 0
			break
	if k == 0:
		print(s)
	else:
		print(s + k * coins[-1])


import math
t = int(input())

def solve():
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if n == 1:
		print(k + 1)
		return
	x = k
	f = False
	for i in range(1, len(arr)):
		v = 10 ** (arr[i] - arr[i - 1]) - 1
		if v <= x:
			x -= v
		else:
			f = True
			break
	if f:
		ans = (x + 1) * 10 ** arr[i - 1] + (10 ** arr[i - 1] - 1)
	else:
		ans = str(x + 1) + str(10 ** arr[i] - 1)
	print(ans)
for _ in range(t):
	solve()


import io
import os
FILE_INPUT_MODE = 0
if FILE_INPUT_MODE >= 0:
	if FILE_INPUT_MODE == 1:
		CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
		FD = os.open(f'{CURRENT_DIR}\\input.txt', os.O_RDONLY)
	elif FILE_INPUT_MODE == 0:
		FD = 0
	DATA = io.BytesIO(os.read(FD, os.fstat(FD).st_size))
	if FD != 0:
		os.close(FD)

	def input():
		return DATA.readline().decode().rstrip('\r\n')

def solve(n, k, a, d):
	ans = 0
	cnt = 0
	for i in range(1, n):
		x = d[a[i] - a[i - 1]] - 1
		if k + 1 - cnt <= x:
			ans += (k + 1 - cnt) * d[a[i - 1]]
			return ans
		ans += x * d[a[i - 1]]
		cnt += x
	ans += (k + 1 - cnt) * d[a[n - 1]]
	return ans

def main():
	t = int(input())
	d = [1]
	for i in range(10):
		d.append(d[-1] * 10)
	for _ in range(t):
		(n, k) = [int(word) for word in input().strip().split()]
		a = [int(word) for word in input().strip().split()]
		print(solve(n, k, a, d))
main()


import bisect
import heapq
import math
import collections
import sys
import copy
from functools import reduce
import decimal
from io import BytesIO, IOBase
import os
import itertools
import functools
from types import GeneratorType
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
graphDict = collections.defaultdict
queue = collections.deque

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		to = f(*args, **kwargs)
		if stack:
			return to
		else:
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						return to
					to = stack[-1].send(to)
	return wrappedfunc

class Graphs:

	def __init__(self):
		self.graph = graphDict(set)

	def add_edge(self, u, v):
		self.graph[u].add(v)
		self.graph[v].add(u)

	def dfs_utility(self, nodes, visited_nodes, colors, parity, level):
		global count
		if nodes == 1:
			colors[nodes] = -1
		elif len(self.graph[nodes]) == 1 and parity % 2 == 0:
			if q == 1:
				colors[nodes] = 1
			else:
				colors[nodes] = -1
				count += 1
		elif parity % 2 == 0:
			colors[nodes] = -1
		else:
			colors[nodes] = 1
		visited_nodes.add(nodes)
		for neighbour in self.graph[nodes]:
			new_level = level + 1
			if neighbour not in visited_nodes:
				self.dfs_utility(neighbour, visited_nodes, colors, level - 1, new_level)

	def dfs(self, node):
		Visited = set()
		color = collections.defaultdict()
		self.dfs_utility(node, Visited, color, 0, 0)
		return color

	def bfs(self, node, f_node):
		count = float('inf')
		visited = set()
		level = 0
		if node not in visited:
			queue.append([node, level])
			visited.add(node)
		flag = 0
		while queue:
			parent = queue.popleft()
			if parent[0] == f_node:
				flag = 1
				count = min(count, parent[1])
			level = parent[1] + 1
			for item in self.graph[parent[0]]:
				if item not in visited:
					queue.append([item, level])
					visited.add(item)
		return count if flag else -1
		return False

class Tree:

	def __init__(self, data):
		self.data = data
		self.left = None
		self.right = None

def inorder(node, lis):
	if node:
		inorder(node.left, lis)
		lis.append(node.data)
		inorder(node.right, lis)
	return lis

def leaf_node_sum(root):
	if root is None:
		return 0
	if root.left is None and root.right is None:
		return root.data
	return leaf_node_sum(root.left) + leaf_node_sum(root.right)

def hight(root):
	if root is None:
		return -1
	if root.left is None and root.right is None:
		return 0
	return max(hight(root.left), hight(root.right)) + 1

class UF:

	def __init__(self, N):
		self._id = list(range(N))
		self._count = N
		self._rank = [0] * N

	def find(self, p):
		id = self._id
		while p != id[p]:
			p = id[p]
		return p

	def count(self):
		return self._count

	def connected(self, p, q):
		return self.find(p) == self.find(q)

	def union(self, p, q):
		id = self._id
		rank = self._rank
		i = self.find(p)
		j = self.find(q)
		if i == j:
			return
		self._count -= 1
		if rank[i] < rank[j]:
			id[i] = j
		elif rank[i] > rank[j]:
			id[j] = i
		else:
			id[j] = i
			rank[i] += 1

	def add_roads(self):
		return set(self._id)

	def __str__(self):
		return ' '.join([str(x) for x in self._id])

	def __repr__(self):
		return 'UF(' + str(self) + ')'

def rounding(n):
	return int(decimal.Decimal(f'{n}').to_integral_value())

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def p_sum(array):
	return list(itertools.accumulate(array))

def base_change(nn, bb):
	if nn == 0:
		return [0]
	digits = []
	while nn:
		digits.append(int(nn % bb))
		nn //= bb
	return digits[::-1]

def diophantine(a: int, b: int, c: int):
	(d, x, y) = extended_gcd(a, b)
	r = c // d
	return (r * x, r * y)

@bootstrap
def extended_gcd(a: int, b: int):
	if b == 0:
		(d, x, y) = (a, 1, 0)
	else:
		(d, p, q) = (yield extended_gcd(b, a % b))
		x = q
		y = p - q * (a // b)
	yield (d, x, y)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, **kwargs):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def inp():
	return sys.stdin.readline().strip()

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
for _ in range(int(inp())):
	(n, k) = map_inp(int)
	arr = map_inp(int)
	arr = [10 ** item for item in arr]
	ans = 0
	for i in range(n - 1):
		(a, b) = divmod(arr[i + 1] - 1, arr[i])
		if a + b > k:
			if k < 10:
				ans = arr[i] + k
				break
			else:
				k += 1
				for item in range(0, n - 1):
					if k < 0:
						break
					ans += min(k, (arr[item + 1] - 1) // arr[item]) * arr[item]
					k -= min(k, (arr[item + 1] - 1) // arr[item])
				if k > 0:
					ans += k * arr[n - 1]
				break
	if ans == 0:
		k += 1
		for item in range(0, n - 1):
			if k < 0:
				break
			ans += min(k, (arr[item + 1] - 1) // arr[item]) * arr[item]
			k -= min(k, (arr[item + 1] - 1) // arr[item])
		if k > 0:
			ans += k * arr[n - 1]
	print(ans)


def solve():
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	goal = k + 1
	out = ''
	for i in range(n):
		if i == n - 1:
			av = 10 ** 15
		else:
			av = 10 ** (a[i + 1] - a[i]) - 1
		if av >= goal:
			out = str(goal) + out
			print(out)
			return
		else:
			out = str(av) + out
			goal -= av
	print(goal)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k += 1
	i = 0
	s = 0
	d = 0
	while i < n - 1 and k > 0:
		d = 10 ** a[i + 1] // 10 ** a[i] - 1
		if k - d < 0:
			s += k * 10 ** a[i]
			k = 0
			break
		else:
			k -= d
			s += d * 10 ** a[i]
		i += 1
	if k > 0:
		s += k * 10 ** a[n - 1]
	print(s)


t = int(input())
while t > 0:
	t -= 1
	myinput = list(map(int, input().split()))
	n = myinput[0]
	k = myinput[1]
	arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	myinput = list(map(int, input().split()))
	for x in myinput:
		arr[x] += 1
	ans = 0
	pv = 1
	for x in range(10):
		if arr[x] > 0:
			pv = 1
		else:
			pv *= 10
		if pv * 9 <= k:
			k -= 9 * pv
			ans += 9 * 10 ** x
		else:
			ans += (k + 1) * int(10 ** x / pv)
			k = -1
			break
	ans += (k + 1) * int(10 ** 9 / pv)
	if arr[0] == 0:
		ans = 1
	print(ans)