Dreamoon is a big fan of the Codeforces contests.

One day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!

Based on this, you come up with the following problem:

There is a person who participated in $n$ Codeforces rounds. His place in the first round is $a_1$, his place in the second round is $a_2$, ..., his place in the $n$-th round is $a_n$.

You are given a positive non-zero integer $x$.

Please, find the largest $v$ such that this person can collect all the places from $1$ to $v$ after $x$ more rated contests.

In other words, you need to find the largest $v$, such that it is possible, that after $x$ more rated contests, for each $1 \leq i \leq v$, there will exist a contest where this person took the $i$-th place.

For example, if $n=6$, $x=2$ and $a=[3,1,1,5,7,10]$ then answer is $v=5$, because if on the next two contest he will take places $2$ and $4$, then he will collect all places from $1$ to $5$, so it is possible to get $v=5$.


-----Input-----

The first line contains an integer $t$ ($1 \leq t \leq 5$) denoting the number of test cases in the input.

Each test case contains two lines. The first line contains two integers $n, x$ ($1 \leq n, x \leq 100$). The second line contains $n$ positive non-zero integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 100$).


-----Output-----

For each test case print one line containing the largest $v$, such that it is possible that after $x$ other contests, for each $1 \leq i \leq v$, there will exist a contest where this person took the $i$-th place.


-----Example-----
Input
5
6 2
3 1 1 5 7 10
1 100
100
11 1
1 1 1 1 1 1 1 1 1 1 1
1 1
1
4 57
80 60 40 20

Output
5
101
2
2
60



-----Note-----

The first test case is described in the statement.

In the second test case, the person has one hundred future contests, so he can take place $1,2,\ldots,99$ and place $101$ on them in some order, to collect places $1,2,\ldots,101$.

Difficulty: EASY

Solutions:
for _ in range(int(input())):
	(n, new) = map(int, input().split())
	arr = list(map(int, input().split()))
	i = 0
	while new > -1:
		i += 1
		if i not in arr:
			new -= 1
	print(i - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	j = 0
	prv = 0
	while j < len(arr):
		if arr[j] == prv:
			del arr[j - 1]
		else:
			prv = arr[j]
			j += 1
	for j in range(len(arr)):
		if arr[j] - j - 1 > x:
			print(x + j)
			break
	else:
		print(x + len(arr))


t = int(input().strip())
for _ in range(t):
	(n, x) = map(int, input().strip().split(' '))
	a = tuple(map(int, input().strip().split(' ')))
	len = n + x + 1
	b = [False] * len
	for e in a:
		if e < len:
			b[e] = True
	ans = None
	for ans in range(1, len):
		if b[ans] == False:
			if x > 0:
				x -= 1
			else:
				ans -= 1
				break
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	i = 0
	while x > 0:
		i += 1
		if i in a:
			continue
		ans += 1
		x -= 1
	while True:
		i += 1
		if i in a:
			continue
		i -= 1
		break
	print(i)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = [int(i) for i in input().split()]
	l = set(l)
	l = list(l)
	d = dict()
	for i in l:
		d[i] = 1
	for i in l:
		if i >= 1 and i <= x:
			x += 1
	while x + 1 in d:
		x = x + 1
	print(x)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	if l[0] == 1:
		p = 1
		i = 2
		while x >= 0 or i in l:
			if i in l:
				p += 1
				i += 1
			elif x > 0:
				p += 1
				x -= 1
				i += 1
			else:
				break
		print(p)
	elif l[0] > x:
		p = x
		i = x + 1
		while i in l:
			i += 1
			p += 1
		print(p)
	else:
		p = l[0]
		x = x + 1 - l[0]
		i = l[0] + 1
		while x >= 0 or i in l:
			if i in l:
				p += 1
				i += 1
			elif x > 0:
				p += 1
				x -= 1
				i += 1
			else:
				break
		print(p)
	t -= 1


import sys
import math

def read_line():
	return sys.stdin.readline()[:-1]

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

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
t = read_int()
for i in range(t):
	(n, x) = read_int_line()
	a = read_int_line()
	b = [0] * 500
	for i in range(n):
		b[a[i]] = 1
	i = 1
	cnt = 0
	while i < len(b) and x > 0:
		if b[i] == 1:
			i += 1
		else:
			b[i] = 1
			x -= 1
			i += 1
	c = 0
	for i in range(1, len(b)):
		if b[i] == 1:
			c += 1
		else:
			break
	print(c)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = set(a)
	b = set(range(1, 201))
	b = b.difference(a)
	b = list(b)
	b = b[x - 1]
	while b + 1 in a:
		b += 1
	print(b)


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')
for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	s = set(l)
	for j in range(1, 204):
		if j not in s:
			if x == 0:
				print(j - 1)
				break
			else:
				x -= 1


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	res = [0] * 1000
	for i in map(int, input().split()):
		res[i - 1] = 1
	ind = 0
	while ind < 1000:
		if res[ind] == 0:
			if m == 0:
				ind -= 1
				break
			else:
				m -= 1
		ind += 1
	print(ind + 1)


for tc in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	dp = [0 for i in range(300)]
	for i in l:
		dp[i] = 1
	i = 1
	while k | dp[i]:
		if not dp[i]:
			k -= 1
			dp[i] = 1
		i += 1
	print(i - 1)


for i in range(int(input())):
	(b, c) = list(map(int, input().split(' ')))
	a = set(list(map(int, input().split(' '))))
	d = 0
	while c > -1:
		d += 1
		if d not in a:
			c -= 1
	print(d - 1)


import sys, math, cmath, time
start_time = time.time()

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

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

def insr():
	s = input()
	return s[:len(s) - 1]

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

def solve():
	(n, k) = invr()
	a = inlt()
	a = list(set(a))
	a.sort()
	c = 0
	a = [0] + a
	for i in range(len(a) - 1):
		if a[i + 1] - a[i] - 1 <= k:
			c = a[i + 1]
			k = k - (a[i + 1] - a[i] - 1)
		else:
			c = a[i] + k
			k = 0
			break
	c = c + k
	print(c)
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
t = 1
t = inp()
for tt in range(t):
	solve()
if not ONLINE_JUDGE:
	print('Time Elapsed:', time.time() - start_time, 'seconds')
sys.stdout.close()


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	inc = 1
	tot = 1
	while tot <= x:
		if inc in a:
			inc += 1
		else:
			a.append(inc)
			inc += 1
			tot += 1
	for k in range(1, 10 ** 5):
		if k in a:
			pass
		else:
			print(k - 1)
			break


t = int(input())
for i in range(t):
	(n, x) = map(int, input().strip().split(' '))
	lst = list(map(int, input().strip().split(' ')))
	lst.sort()
	lst = list(dict.fromkeys(lst))
	j = 0
	k = 0
	f = 0
	while j != x:
		if k < len(lst):
			if lst[k] != k + 1:
				lst.insert(k, k + 1)
				j += 1
				k += 1
			else:
				k += 1
		else:
			lst.append(k + 1)
			j += 1
	j = 0
	while j < len(lst):
		if lst[j] == j + 1:
			j += 1
		else:
			print(j)
			f = 1
			break
	if f == 0:
		print(j)


import sys
input = sys.stdin.readline
from collections import defaultdict as dd
t = int(input())
while t:
	(n, m) = map(int, input().split())
	l = set(map(int, input().split()))
	l = list(l)
	d = dd(int)
	for i in l:
		d[i] = 1
	for i in range(1, 1000):
		if m == 0 and d[i] == 0:
			break
		elif d[i] == 0:
			ind = i
			m -= 1
		else:
			ind = i
	print(ind)
	t -= 1


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l = list(set(l))
	l.sort()
	count = 1
	i = 0
	while i < len(l):
		if l[i] == count:
			count += 1
			i += 1
			continue
		elif x > 0:
			x -= 1
			count += 1
		else:
			break
	if x == 0:
		print(count - 1)
	else:
		print(count + x - 1)


output = []
for __ in range(int(input())):
	(N, X) = [int(num) for num in input().split()]
	A = [int(num) for num in input().split()]
	c = 0
	while True:
		if c + 1 in A:
			c += 1
		elif X > 0:
			c += 1
			X -= 1
		else:
			break
	output.append(c)
for o in output:
	print(o)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = [0] * 101
	for i in l:
		l1[i] += 1
	i = 1
	ans = 0
	while i <= 100:
		if l1[i] == 0:
			k -= 1
			ans += 1
		else:
			ans += 1
		if not k:
			i += 1
			while i <= 100 and l1[i] != 0:
				ans += 1
				i += 1
			break
		i += 1
	if k > 0:
		ans += k
	print(ans)


t = int(input())
for t1 in range(0, t):
	(v, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = set(l)
	ans = 1
	while x > 0:
		if ans not in s:
			ans += 1
			x = x - 1
		else:
			ans += 1
	ans = ans - 1
	while ans + 1 in s:
		ans += 1
	print(ans)


import bisect
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = [0] + sorted(list(set([int(x) for x in input().split()])))
	ans = 0
	for i in range(len(a)):
		t = a[i] - i
		if t == x:
			ans = a[i]
		if t < x:
			ans = a[i - 1] + x - (a[i - 1] - i)
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	j = 0
	ind = 1
	while j <= x:
		if ind not in a:
			if j == x:
				break
			j += 1
		ind += 1
	print(ind - 1)


t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a = list(set(a))
	a.sort()
	(res, check) = (0, 0)
	for i in range(1, 500):
		if i not in a:
			res += 1
		if res == x:
			check = 1
			continue
		if check == 1:
			if i not in a:
				print(i - 1)
				break


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = a
	a = list(set(a))
	a.sort()
	ult = 0
	c = 0
	lena = len(a)
	if x == 1 and lena == 1:
		if x < a[0]:
			if x + 1 == a[0]:
				print(x + 1)
				continue
			else:
				print(x)
				continue
		elif x > a[0]:
			print(x + 1)
			continue
	if lena == 1:
		if x < a[0]:
			if x + 1 == a[0]:
				print(x + 1)
				continue
			else:
				print(x)
				continue
		elif x > a[0]:
			print(x + 1)
			continue
	for i in range(lena):
		aux = a[0:i + 1]
		tam = len(aux) + x
		if tam == a[i]:
			if a[i] > ult:
				ult = a[i]
		elif tam > a[i]:
			if len(aux) + x > ult:
				ult = tam
		else:
			c += 1
	if c == lena - 1:
		print(x + 1)
	else:
		print(ult)


t = int(input())
for _ in range(t):
	ans = 0
	(n, x) = map(int, input().split())
	l = [int(i) for i in input().split()]
	i = 1
	while True:
		if i not in l:
			x -= 1
		if x < 0:
			ans = i - 1
			break
		i += 1
	print(ans)


for lo in range(int(input())):
	(n, x) = map(int, input().split())
	ls = [int(x) for x in input().split()]
	a = [0 for i in range(210)]
	for i in ls:
		a[i] = 1
	i = 1
	while x > 0:
		if a[i] == 0:
			a[i] = 1
			x -= 1
		i += 1
	while a[i] == 1:
		i += 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = 0
	for y in sorted(map(int, input().split())):
		if a + x >= y - 1:
			x -= max(0, y - a - 1)
			a = y
		else:
			break
	print(a + x)


R = lambda : map(int, input().split())
(t,) = R()
exec(t * 'n,x=R();print(sorted({*range(1,202)}-{*R()})[x]-1);')


import time
import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import bisect_left, bisect_right
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string, heapq as h
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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 getInt():
	return int(input())

def getStrs():
	return input().split()

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

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def getBin():
	return list(map(int, list(input())))

def isInt(s):
	return '0' <= s[0] <= '9'

def ceil_(a, b):
	return a // b + (a % b > 0)
MOD = 10 ** 9 + 7

def solve():
	(N, X) = getInts()
	A = getInts()
	used = set(A)
	j = 1
	for i in range(X):
		while j in used:
			j += 1
		used.add(j)
	while j in used:
		j += 1
	return j - 1
for _ in range(getInt()):
	print(solve())


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(1, 201):
		if i not in a:
			x -= 1
			if x < 0:
				i -= 1
				break
	print(i)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	count = x
	ans = 0
	for j in range(1, max(a) + x + 2):
		if j in a:
			continue
		elif count > 0:
			count -= 1
		else:
			break
	print(j - 1)


repeat = int(input())
answer = []
for i in range(repeat):
	(loose, extra_round) = map(int, input().split())
	all_positions = list(map(int, input().split()))
	find = 1
	while extra_round > 0:
		if all_positions.count(find) == 0:
			extra_round -= 1
			all_positions.append(find)
		find += 1
	find = 1
	while True:
		if all_positions.count(find) == 0:
			break
		find += 1
	answer.append(find - 1)
for show in answer:
	print(show)


import sys
input = sys.stdin.readline

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

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

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

def si():
	return input()[:-1]

def solve():
	(n, x) = iit()
	a = iil()
	a.sort()
	j = 1
	for i in range(n):
		if i > 0 and a[i] == a[i - 1]:
			continue
		if a[i] == j:
			j += 1
			continue
		d = a[i] - j
		if d > x:
			print(j + x - 1)
			return
		else:
			x -= d
			j = a[i] + 1
	print(j + x - 1)
CASES = True
if CASES:
	t = ii()
	for i in range(t):
		solve()
else:
	solve()


import bisect
import os
import io
from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
from collections import deque
import threading
sys.setrecursionlimit(200000)

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

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

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)))
for _ in range(iinput()):
	(n, x) = rinput()
	a = rlinput()
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	ans = 0
	for i in range(1, 201):
		if i in d:
			ans += 1
		else:
			if x == 0:
				break
			x -= 1
			ans += 1
	print(ans)


n = int(input())
for i in range(n):
	(a, b) = input().split()
	b = int(b)
	x = [int(x) for x in input().split()]
	c = 0
	for i in range(b):
		c = c + 1
		while c in x:
			c = c + 1
	while c + 1 in x:
		c = c + 1
	print(c)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l1.sort()
	i = 1
	j = 0
	d1 = {}
	for k in l1:
		d1[k] = 1
	while x or i in d1:
		if i in d1:
			i += 1
		else:
			x -= 1
			i += 1
	print(i - 1)


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


from collections import defaultdict
t = int(input())
for i in range(t):
	(n, x) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	arr1 = [0] * 1000
	for i in arr:
		arr1[i] = 1
	for i in range(1, len(arr1)):
		arr1[i] += arr1[i - 1]
	ans = 0
	for i in range(1, 1000):
		if i - arr1[i] <= x:
			ans = max(ans, i)
	print(ans)


def main():
	import sys
	input = sys.stdin.readline
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		A = list(map(int, input().split()))
		A.sort()
		ans = 0
		for i in range(n):
			if A[i] == ans + 1:
				ans += 1
			elif A[i] > ans + 1:
				if x >= A[i] - ans - 1:
					x -= A[i] - ans - 1
					ans = A[i]
				else:
					break
		ans += x
		print(ans)
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	visited = set()
	for i in range(n):
		visited.add(a[i])
	for i in range(1, 202):
		if i not in visited:
			x -= 1
			if x == -1:
				print(i - 1)
				break


n = int(input())
for i in range(n):
	(d, t) = map(int, input().split())
	arr = sorted(list(map(int, input().split())))
	k = s = 1
	while t > 0:
		if k in arr:
			k = k + 1
		else:
			s = k
			t = t - 1
			k = k + 1
	if s + 1 in arr:
		while s + 1 in arr:
			s = s + 1
		print(s)
	else:
		print(s)


z = int(input())
for _ in range(z):
	(x, y) = map(int, input().split())
	arr = set(map(int, input().split()))
	data = list(arr)
	data.sort()
	for i in range(len(data)):
		if data[i] <= y or data[i] == y + 1:
			y += 1
	print(y)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	v = 0
	for i in range(1, 201):
		if i in a:
			v = i
		elif x != 0:
			x -= 1
			v = i
		else:
			break
	print(v)


for _ in [0] * int(input()):
	(n, x) = map(int, input().split())
	a = {*map(int, input().split())}
	r = 1
	while x or r in a:
		x -= r not in a
		r += 1
	print(r - 1)


t = int(input())
for T in range(t):
	(n, x) = map(int, input().split())
	v = sorted(set(map(int, input().split())))
	last = 0
	s = 0
	for i in v:
		if i - last - 1 + s <= x:
			s += i - last - 1
		else:
			break
		last = i
	if s < x:
		last += x - s
	print(last)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ar = [int(y) for y in input().split()[:n]]
	br = [0] * 200
	for j in ar:
		br[j - 1] = 1
	k = 0
	ans = 0
	for j in br:
		if j == 0:
			k = k + 1
		if k >= x + 1:
			break
		ans = ans + 1
	print(ans)


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	Dict = defaultdict(int)
	for i in arr:
		Dict[i] = 1
	start = 1
	m = max(arr)
	flag = 0
	val = -1
	for i in range(1, m + 1):
		if Dict[i] == 0:
			if x == 0:
				flag = 1
				val = i
				break
			x -= 1
	if flag == 1:
		print(val - 1)
	else:
		print(m + x)


I = lambda : map(int, input().split())
for _ in range(int(input())):
	(_, x) = I()
	for a in sorted(set(I())):
		if a <= x + 1:
			x += 1
	print(x)


t = int(input())

def unique(arr):
	final = []
	arr.sort()
	for x in arr:
		n = len(final)
		if n > 0 and final[n - 1] == x:
			continue
		final.append(x)
	return final
while t > 0:
	t -= 1
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a = unique(a)
	max = 0
	for i in range(len(a)):
		if x <= 0:
			if a[i] == max + 1:
				max += 1
				continue
			else:
				break
		if a[i] != max + 1:
			r = a[i] - (max + 1)
			if x >= r:
				x -= r
			else:
				max = max + x
				x = 0
				break
		max = a[i]
	if x > 0:
		max += x
	print(max)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = sorted(list(set(map(int, input().split()))))
	counter = 0
	i = 1
	while counter < x:
		if i not in a:
			a.append(i)
			counter += 1
		i += 1
	a.sort()
	c = 1
	res = 0
	while True:
		if c not in a:
			break
		res += 1
		c += 1
	print(res)


def main():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		m = max(a) + n + x
		bit_a = [0] * m
		for i in a:
			bit_a[i - 1] = 1
		for i in range(m):
			if not bit_a[i]:
				bit_a[i] = 1
				x -= 1
			if x == 0:
				break
		print(bit_a.index(0))
main()


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	s = list(map(int, input().split()))
	s.sort()
	s = sorted(set(s))
	ans = x
	am = 0
	for i in s:
		am += 1
		if x + am >= i:
			ans = x + am
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [0] * (max(a) + x + n + 10)
	for i in range(len(a)):
		l[a[i]] += 1
	for i in range(1, len(l)):
		if l[i] == 0 and x > 0:
			l[i] = 1
			x -= 1
	for i in range(1, len(l)):
		if l[i] == 0:
			print(i - 1)
			break


t = int(input())
for i in range(t):
	(n, x) = input().split(' ')
	n = int(n)
	x = int(x)
	a = [int(x) for x in input().split(' ')]
	r = 0
	b = 1
	j = 1
	while b == 1:
		if j in a:
			r += 1
		elif x > 0:
			x -= 1
			r += 1
		else:
			b = 0
		j += 1
	print(r)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	l = []
	for i in range(101):
		l.append(0)
	for i in range(n):
		l[a[i]] = 1
	for i in range(1, 101):
		if l[i] == 0:
			x -= 1
		if x == -1:
			i = i - 1
			break
	if x == -1:
		print(i)
	else:
		print(i + x)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		(n, x) = map(int, input().split())
		aa = [int(a) for a in input().split()]
		bb = [False] * 101
		for a in aa:
			bb[a] = True
		for i in range(1, 101):
			if not bb[i]:
				x -= 1
				if x == -1:
					break
		else:
			print(100 + x)
			return
		print(i - 1)
	q = int(input())
	for _ in range(q):
		solve()
main()


def main():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		y = list(map(int, input().split()))
		v = 0
		i = 1
		while True:
			if i not in y:
				if x == 0:
					break
				x -= 1
				y.append(i)
			i += 1
		i = 1
		while True:
			if i not in y:
				print(i - 1)
				break
			i += 1
main()


def main():
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	for k in range(n + x, -1, -1):
		cnt = 0
		for i in range(1, k + 1):
			if not i in arr:
				cnt += 1
		if cnt <= x:
			print(k)
			break
for q in range(int(input())):
	main()


import collections, math
local = False
if local:
	file = open('inputt.txt', 'r')

def inp():
	if local:
		return file.readline().rstrip()
	else:
		return input().rstrip()

def ints():
	return [int(_) for _ in inp().split()]
t = int(inp())
for _ in range(t):
	(n, x) = ints()
	arr = set(ints())
	ans = 0
	for i in range(1, 300):
		if i in arr:
			ans += 1
		else:
			x -= 1
			if x < 0:
				break
			ans += 1
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	f = [0] * 205
	a = map(int, input().split())
	for i in a:
		f[i] = 1
	res = 1
	while x:
		if not f[res]:
			x -= 1
			f[res] = 1
		res += 1
	res -= 1
	while f[res]:
		res += 1
	print(res - 1)


import sys
import math

def alele():
	return list(map(int, sys.stdin.readline().strip().split()))

def ilele():
	return map(int, sys.stdin.readline().strip().split())

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
import bisect
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(input())):
	(n, x) = ilele()
	A = alele()
	A.sort()
	count = 0
	for i in range(1, 1000):
		if i in A:
			continue
		elif count != x:
			bisect.insort(A, i)
			count += 1
		else:
			print(i - 1)
			break


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set(a)
	k = 0
	c = 1
	while 1:
		if k > x:
			break
		if c not in s:
			k += 1
		c += 1
	print(c - 2)


def solution(n, x, arr):
	cache = [False] * 201
	for e in arr:
		cache[e - 1] = True
	for i in range(len(cache)):
		if cache[i] == False and x > 0:
			cache[i] = True
			x -= 1
		if x <= 0:
			break
	for (j, b) in enumerate(cache):
		if b == False:
			return j
for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	print(solution(n, x, a))


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	lst = [int(i) for i in input().split()]
	u = 1
	while x != -1:
		if u not in lst:
			x -= 1
		u += 1
	print(u - 2)


t = int(input())
for _ in range(t):
	(n, x) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	dp = [0] * 101
	for i in a:
		dp[i] = 1
	sm = 0
	i = 1
	while i < len(dp) and x > 0:
		if dp[i] == 0:
			x -= 1
		i += 1
	if x > 0:
		i -= 1
		i += x
	else:
		while i < len(dp) and dp[i] == 1:
			i += 1
		i -= 1
	print(i)


t = int(input())
while t:
	t -= 1
	(n, x) = [int(s) for s in input().split()]
	a = [int(s) for s in input().split()]
	done = [0 for i in range(n + x)]
	for i in a:
		if i <= n + x:
			done[i - 1] = 1
	count = 0
	for i in range(len(done)):
		if x > 0:
			if done[i] == 0:
				x = x - 1
				done[i] = 1
	for i in range(len(done)):
		if done[i] == 0:
			break
		count = count + 1
	print(count)


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	x = int(l[1])
	l = input().split()
	li = [int(i) for i in l]
	li.append(10 ** 9)
	li.append(0)
	li.sort()
	for i in range(n + 1):
		if li[i + 1] - li[i] == 0:
			continue
		k = li[i + 1] - li[i] - 1
		if x >= k:
			x -= k
		else:
			ans = li[i] + x
			break
	print(ans)


t = int(input())
for i in range(t):
	line = [int(j) for j in input().split()]
	(n, x) = (line[0], line[1])
	a = [int(j) for j in input().split()]
	a = sorted(set(a))
	counter = 0
	i = 0
	while i < len(a) or x != 0:
		if i < len(a) and a[i] == counter + 1:
			counter += 1
			i += 1
		elif x > 0:
			counter += 1
			x -= 1
		else:
			break
		if i == len(a) and x == 0:
			break
	print(counter)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	i = 1
	while x != 0:
		if i not in l:
			x = x - 1
		if x == 0:
			break
		i = i + 1
	while i + 1 in l:
		i = i + 1
	print(i)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	xi = x
	l_set = set(l)
	i = 1
	while x != 0:
		if i not in l_set:
			l_set.add(i)
			x -= 1
		i += 1
	l_set = list(l_set)
	l_set.sort()
	for i in range(1, n + xi + 2):
		if i not in l_set:
			print(i - 1)
			break


t = int(input())
for q in range(t):
	(n, x) = map(int, input().split())
	used = [0] * 301
	a = list(map(int, input().split()))
	for i in range(n):
		used[a[i]] = 1
	i = 0
	while x >= 0:
		i += 1
		if used[i] == 0:
			x -= 1
	print(i - 1)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	x = [0] * 201
	for i in range(n):
		x[l[i] - 1] = 1
	c = 0
	for i in range(201):
		if x[i] == 0:
			x[i] += 1
			c += 1
		if c == m:
			break
	c = 0
	for i in x:
		if i == 0:
			break
		c += 1
	print(c)


def main():
	T = int(input())
	for t in range(T):
		(n, x) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		ranks = [0 for i in range(200)]
		for va in a:
			ranks[va - 1] = 1
		ans = x
		for i in range(200):
			if x == 0 and ranks[i] == 0:
				break
			if ranks[i] == 0:
				x -= 1
			ans = i + 1
		print(ans)
main()


for _ in range(int(input())):
	(n, r) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	i = 1
	nd = 0
	while r >= 0:
		if i in lst:
			nd += 1
		elif r == 0:
			r = r - 1
		else:
			nd += 1
			r = r - 1
		i += 1
	print(nd)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(set(a))
	a.sort()
	for i in a:
		if i <= x:
			x += 1
		if i == x + 1:
			x += 1
	print(x)


t = int(input())
while t != 0:
	(n, x) = map(int, input().split())
	list1 = list(map(int, input().split()))
	dict = {}
	for i in range(500):
		dict[i] = 0
	for i in range(n):
		dict[list1[i]] = 1
	for i in range(1, 500):
		if dict[i] == 0:
			x -= 1
			if x == 0:
				for j in range(i + 1, 500):
					if dict[j] == 0:
						print(j - 1)
						break
				break
	t -= 1


t = int(input())
for i in range(0, t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	arr = list(map(int, input().split()))
	arr.sort()
	arr = set(arr)
	arr = list(arr)
	arr.sort()
	ans = 0
	freq = [0] * 210
	for j in range(0, len(arr)):
		freq[arr[j]] = 1
	k = 1
	while x > 0 and k < 210:
		if freq[k] == 0:
			x = x - 1
			freq[k] = 1
		k = k + 1
	count = 0
	l = 1
	while l < 210 and freq[l] != 0:
		count = count + 1
		l = l + 1
	if l == arr[-1] + 1:
		pass
	print(count)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(set(list(map(int, input().split()))))
	i = 1
	while True:
		if x == 0:
			break
		if i not in arr:
			x -= 1
		i += 1
	ans = i - 1
	while i in arr:
		ans += 1
		i += 1
	print(ans)


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	arr = [0] * 202
	for i in range(n):
		arr[a[i]] = 1
	k = 1
	v = 0
	for i in range(1, 202):
		if arr[i] == 0 and k <= x:
			arr[i] = 1
			k += 1
	ch = 0
	for i in range(1, 202):
		if arr[i] == 0:
			v = i - 1
			break
		v = i
	print(v)


def solve(n, x, placements):
	for i in range(n - 1):
		(p1, p2) = (placements[i], placements[i + 1])
		if p1 == p2 or p1 + 1 == p2:
			continue
		elif x == 0:
			return p1
		elif p2 - p1 - 1 > x:
			return p1 + x
		else:
			x -= p2 - p1 - 1
	else:
		return placements[-1] + x
num_tests = int(input())
for _ in range(num_tests):
	(n, x) = map(int, input().split())
	placements = [0]
	for i in input().split():
		placements.append(int(i))
	print(solve(n + 1, x, sorted(placements)))


from fractions import Fraction
from collections import defaultdict
import math
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	l = list([int(x) for x in input().split()])
	s = set(l)
	c = 0
	i = 1
	while c < x:
		if i not in s:
			c += 1
			s.add(i)
		else:
			i += 1
	if i in s:
		while i in s:
			i += 1
	print(i - 1)


t = int(input())
while t != 0:
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	lst2 = []
	j = 1
	while True:
		if j in lst:
			lst2.append(j)
			j += 1
		elif x != 0:
			lst2.append(j)
			x -= 1
			j += 1
		else:
			break
	print(len(lst2))
	t -= 1


ans = []
for _ in range(int(input())):
	a = list(map(int, input().split()))
	n = a[0]
	x = a[1]
	a = list(map(int, input().split()))
	v = 0
	while x != -1:
		v += 1
		if v not in a:
			x -= 1
	ans.append(v - 1)
for i in ans:
	print(i)


for _ in range(int(input())):
	ans = [0] * 1000000
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n):
		ans[a[i]] += 1
	for i in range(1, 1000000):
		if ans[i] == 0 and x > 0:
			ans[i] = 1
			x -= 1
		elif x == 0:
			break
	for i in range(1, 1000000):
		if ans[i] != 0 and ans[i + 1] == 0:
			print(i)
			break


t = int(input())
for _ in range(t):
	ar = [0 for i in range(300)]
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in a:
		ar[i - 1] = 1
	out = 0
	while ar[out] != 0 or x != 0:
		if ar[out] == 0:
			x -= 1
		out += 1
	print(out)


t = int(input())
ans = []
for i in range(t):
	(n, x) = map(int, input().split())
	places = set(map(int, input().split()))
	j = 1
	counter = 0
	while counter <= x:
		if j not in places:
			counter += 1
		j += 1
	ans.append(j - 2)
for i in ans:
	print(i)


t = int(input())
res = ''
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(set(map(int, input().split())))
	a.sort()
	cur = 0
	for elem in a:
		delta = elem - cur - 1
		if delta <= x:
			x -= delta
			cur = elem
		else:
			cur += x
			x = 0
	res += str(cur + x) + '\n'
print(res)


import math
t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	arr = set([int(x) for x in input().split()])
	non = set((x for x in range(1, 210) if x not in arr))
	for j in range(x):
		non.discard(min(non))
	print(min(non) - 1)


from sys import stdin, stdout
import bisect
import math

def main():
	for _ in range(int(stdin.readline())):
		(n, x) = map(int, stdin.readline().split())
		arr = [int(k) for k in stdin.readline().split()]
		mx = 0
		dic = {}
		counter = 0
		num = 0
		for i in range(n):
			if arr[i] not in dic:
				dic[arr[i]] = 1
			mx = max(mx, arr[i])
		for i in range(1, mx + 1):
			if i in dic:
				continue
			elif x <= 0:
				num = i - 1
				counter = 1
				break
			else:
				x -= 1
		if counter == 1:
			print(num)
		else:
			print(mx + x)
main()


k = int(input().strip())
for _ in range(k):
	(n, x) = input().strip().split(' ')
	(n, x) = (int(n), int(x))
	l = sorted(list(map(int, input().strip().split(' '))))
	j = 0
	d = 0
	for i in l:
		if i == j:
			continue
		if d + i - j - 1 > x:
			break
		d += i - j - 1
		j = i
	print(j + x - d)


t = int(input())
for i in range(t):
	(n, x) = [int(k) for k in input().split()]
	pos = [int(k) for k in input().split()]
	dic = {}
	for k in range(1, n + x + 2):
		dic[k] = 0
	for s in pos:
		dic[s] = 1
	i = 1
	tp = x
	while tp > 0 and i < n + x + 1:
		if dic[i] == 0:
			tp -= 1
		i += 1
	while dic[i] == 1:
		i += 1
	print(i - 1)


t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	v = 0
	for i in range(1, 201):
		if i in lst:
			v = i
		elif i not in lst and x > 0:
			x -= 1
			v = i
		else:
			break
	print(v)


from collections import Counter

def solve(a, x):
	count = Counter(a)
	prev = 0
	for n in range(1, 500):
		if n not in count:
			x -= 1
		if x == -1:
			prev = n - 1
			break
	return prev

def main():
	t = int(input())
	ans = []
	for _ in range(t):
		(n, x) = [int(x) for x in input().split()]
		a = [int(x) for x in input().split()]
		ans.append(solve(a, x))
	for res in ans:
		print(res)
main()


def binary(arr, x, n):
	ans = -1
	low = 1
	high = n + x
	while low <= high:
		r = 0
		mid = low + (high - low) // 2
		for i in range(1, mid + 1):
			if i not in arr:
				r += 1
		if r <= x:
			ans = mid
			low = mid + 1
		else:
			high = mid - 1
	return ans
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	soln = binary(arr, x, n)
	print(soln)


t = int(input())
for wer in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	aset = set(a)
	vmax = 0
	vst = 0
	i = 1
	while vst != x:
		if i not in aset:
			aset.add(i)
			vst += 1
		i += 1
	i = 1
	while i in aset:
		i += 1
	print(i - 1)


n = int(input())
for i in range(n):
	s = input().split(' ')
	m = int(s[0])
	a = int(s[1])
	s1 = input().split(' ')
	c = [0] * m
	for j in range(m):
		c[j] = int(s1[j])
	c.sort()
	b = 0
	tmps = ''
	while a > 0:
		b += 1
		if c.count(b) == 0:
			a -= 1
			tmps += str(b) + ' '
	while c.count(b + 1) > 0:
		b += 1
	print(b)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * 201
	for i in range(len(a)):
		b[a[i]] = 1
	for i in range(n + x, -1, -1):
		temp = 0
		for j in range(1, i + 1):
			if not b[j]:
				temp += 1
		if temp <= x:
			print(i)
			break


def main():
	t = int(input())
	for __ in range(t):
		(n, k) = map(int, input().split())
		a = list(set(map(int, input().split())))
		a.sort()
		n = len(a)
		found = False
		for i in range(n - 1, -1, -1):
			if a[i] - i - 1 <= k:
				print(a[i] + (k - (a[i] - i - 1)))
				found = True
				break
		if not found:
			print(k)
main()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [0] * 1000
	for i in a:
		l[i - 1] = 1
	c = 0
	for i in range(len(l)):
		if x == 0:
			break
		if l[i] == 0:
			x -= 1
			l[i] = 1
	for i in range(len(l)):
		if l[i] == 0:
			c = i
			break
	print(c)


def input_line_int():
	return [int(x) for x in input().split()]
[t] = input_line_int()
for _ in range(t):
	[n, x] = input_line_int()
	num = input_line_int()
	exist = {}
	for v in num:
		exist[v] = 1
	ans = x
	cnt = 1
	for v in sorted(exist):
		if v - cnt > x:
			break
		ans = max(ans, x + cnt)
		cnt += 1
	print(ans)


Q = int(input())
for _ in range(Q):
	judge = False
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A = list(set(A))
	A.sort(reverse=True)
	for i in range(1, 300):
		if i in A:
			if A:
				A.pop(-1)
			else:
				judge = True
		elif x > 0:
			x -= 1
		else:
			judge = True
		if judge:
			print(i - 1)
			break


t = int(input())
for i in range(t):
	a = 0
	v = 0
	(n, x) = map(int, input().split())
	lsta = input().split()
	lsta.sort()
	while x > 0:
		if str(v + 1) in lsta:
			v += 1
		else:
			v += 1
			x -= 1
	while str(v + 1) in lsta:
		v += 1
	print(v)


import sys
input = sys.stdin.readline
from math import *
from collections import *
t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	st = 0
	s = 0
	dif = 0
	for i in a:
		ndi = i - st
		if ndi != 0:
			ndi -= 1
		if x - ndi < 0:
			break
		else:
			s += ndi
			st = i
			x -= ndi
	st = st + x
	print(st)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list((int(num) for num in input().split()))
	x1 = x
	for z in range(1, n + x + 1):
		if x == 0:
			break
		if z not in a:
			a.append(z)
			x -= 1
	c1 = 0
	for z in range(1, n + x1 + 1):
		if z not in a:
			c1 = 1
			break
	print(z - 1 if c1 else z)


t = int(input())
for q in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = [0] * (max(a) + 1)
	for i in a:
		ans[i] = 1
	i = 1
	while x > 0:
		if ans[i] == 0:
			ans[i] = 1
			x -= 1
		if i == max(a):
			break
		i += 1
	if i == max(a):
		print(max(a) + x)
	else:
		count = 0
		for i in ans[1:]:
			if i == 1:
				count += 1
			else:
				break
		print(count)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(1, 301):
		if i in a:
			continue
		if x:
			x -= 1
			continue
		print(i - 1 + x)
		break


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	(*a,) = map(int, input().split())
	ex = [0] * 300
	for i in a:
		ex[i] = 1
	for i in range(299):
		ex[i + 1] += ex[i]
	ans = 0
	for i in range(300):
		if ex[i] + x >= i:
			ans = i
	print(ans)


T = int(input())
for test in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	check = [0 for _ in range(202)]
	for i in a:
		check[i] = 1
	for i in range(1, len(check)):
		if check[i] != 1:
			check[i] = 1
			x -= 1
		if x == 0:
			break
	count = 0
	for i in range(1, len(check)):
		if check[i] != 1:
			count = i - 1
			break
	print(count)


for _ in range(int(input())):
	(_, x) = map(int, input().split())
	li1 = list(set(map(int, input().split())))
	count = x
	for i in li1:
		if i <= count:
			count += 1
	while count + 1 in li1:
		count += 1
	print(count)


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	ar = list(map(int, input().split()))
	limit = 2 * (n + x)
	hashmap = [0] * (2 * (n + x))
	for i in ar:
		if i < limit:
			hashmap[i] = 1
	for i in range(1, len(hashmap)):
		if hashmap[i] == 1:
			continue
		else:
			if x == 0:
				break
			x = x - 1
	print(i + x - 1)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	i = 1
	b = []
	while not k == 0:
		if i not in a:
			k = k - 1
		b.append(i)
		i += 1
	for j in range(len(a)):
		if i in a:
			b.append(i)
		else:
			break
		i += 1
	print(len(b))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ar = set(map(int, input().split()))
	ans = 0
	for i in range(1, n + x + 2):
		if i in ar:
			ans = i
		elif x > 0:
			ar.add(i)
			ans = i
			x -= 1
		else:
			break
	print(ans)


testCases = int(input())
for _ in range(testCases):
	(n, x) = map(int, input().split())
	contestRankings = set(map(int, input().split()))
	check = 0
	while x > -1:
		check += 1
		if check not in contestRankings:
			x -= 1
	print(check - 1)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	places = list(map(int, input().split()))
	dp = [0 for _ in range(101)]
	dp[0] = -1
	for i in range(len(places)):
		dp[places[i]] += 1
	i = 1
	while i < 101 and x > 0:
		if dp[i] == 0:
			dp[i] = 1
			x -= 1
		i += 1
	if x != 0 and i == 101:
		print(100 + x)
	else:
		i = 1
		while i < 101 and dp[i] != 0:
			i += 1
		print(i - 1)
	t -= 1


t = int(input())
a = 0

def delete_duplicates(arr):
	new_arr = []
	for i in arr:
		if i not in new_arr:
			new_arr.append(i)
	return new_arr
while a < t:
	(n, x) = map(int, input().split())
	a_list = map(int, input().split())
	a_list = delete_duplicates(a_list)
	a_list.sort()
	length = len(a_list)
	for i in range(length):
		index = length - i - 1
		a_i = a_list[index]
		check = x - (a_i - 1 - index)
		if check >= 0:
			print(check + a_i)
			break
		if index == 0:
			print(x)
	a = a + 1


t = int(input())
for i in range(t):
	(n, x) = map(int, input().strip().split())
	l = list(map(int, input().strip().split()))
	count = [0] * max(l)
	for i in l:
		count[i - 1] = 1
	ans = 0
	flag = 0
	for i in range(max(l)):
		if count[i] == 0 and x != 0:
			count[i] = 1
			x = x - 1
		if x == 0:
			flag = 1
		if count[i] == 0 and flag == 1:
			ans = i
			break
	if x != 0:
		ans = max(l) + x
	if ans < len(count):
		flag = 0
		for i in range(len(count)):
			if count[i] == 0:
				flag = 1
				break
		if flag == 0:
			ans = len(count)
	print(ans)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	e = sorted(list(map(int, input().split())))
	d = []
	for j in range(10000):
		d.append(0)
	for j in range(a):
		if d[e[j]] == 0:
			d[e[j]] = 1
	count = 0
	j = 1
	flag = 0
	while True:
		if d[j] == 0:
			if flag == 1:
				break
			else:
				count = count + 1
		if count == b and flag == 0:
			flag = 1
		j = j + 1
	print(j - 1)


def calc(x, ln):
	curr = 0
	while x >= 0:
		if x == 0:
			if curr + 1 in ln:
				curr += 1
				ln.remove(curr)
			else:
				x -= 1
		elif curr + 1 in ln:
			curr += 1
			ln.remove(curr)
		else:
			curr += 1
			x -= 1
	return curr
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ln = sorted(list(set(map(int, input().split()))))
	print(calc(x, ln))


try:
	t = int(input())
	for i in range(t):
		(n, x) = map(int, input().split())
		l = list(map(int, input().split()))
		l1 = []
		y = max(l)
		for i in range(1, n + x + 1):
			if l.count(i) == 0 and x > 0:
				l1.append(1)
				x = x - 1
			elif l.count(i) == 0 and x == 0:
				l1.append(0)
			else:
				l1.append(1)
		if l1.count(0) == 0:
			ans = len(l1)
		else:
			ans = l1.index(0)
		print(ans)
except EOFError:
	pass


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	now = 0
	for i in a:
		if i == now + 1:
			now += 1
		elif i > now:
			if x >= i - now - 1:
				x -= i - now - 1
				now = i
			else:
				now += x
				x = 0
	now += x
	print(now)


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a = sorted(list(set(a)), reverse=True)
	res = len(a) + x
	for p in a:
		if p > res:
			res -= 1
		else:
			break
	print(res)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = sorted(list(set(map(int, input().split()))))
	for i in range(1, 202):
		if i not in l:
			b -= 1
		if b == -1:
			print(i - 1)
			break


from sys import exit as sys_ret
t = int(input())
for _ in range(t):
	possible = [0 for i in range(210)]
	(amount, moves) = map(int, input().split())
	tmp = [int(x) for x in input().split()]
	for i in tmp:
		possible[i] = 1
	i = 1
	while moves != 0:
		if possible[i] == 0:
			moves -= 1
			possible[i] = 1
		i += 1
	(res, i) = (0, 1)
	while possible[i] != 0:
		res += 1
		i += 1
	print(res)


lines = int(input())
for i in range(lines):
	ans = 0
	(n, x) = map(int, input().split())
	inputs = input().split()
	inputs = [int(_) for _ in inputs]
	i = 1
	while True:
		if i not in inputs:
			x -= 1
		if x < 0:
			ans = i - 1
			break
		i += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a.sort()
	ls = [0] * 305
	for i in a:
		ls[i] = 1
	ans = 0
	for i in range(1, 305):
		if ls[i] == 0:
			if m == 0:
				ans = i - 1
				break
			else:
				m -= 1
	print(ans)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	while x > -1:
		i += 1
		if i not in a:
			x -= 1
	print(i - 1)


testcases = int(input())
for case in range(testcases):
	(n, x) = [int(zax) for zax in input().split()]
	l = [int(zax) for zax in input().split()]
	l.sort()
	table = [False for i in range(220)]
	for i in range(n):
		table[l[i]] = True
	i = 1
	count = 0
	while True:
		if x == 0 and (not table[i]):
			break
		elif x == 0 and table[i]:
			count = i
			i += 1
		elif not table[i]:
			x -= 1
			count = i
			i += 1
		else:
			count = i
			i += 1
	print(count)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	n = max(arr) + x + 1
	res = [0] * n
	for i in arr:
		res[i] = 1
	for i in range(1, n):
		if res[i] != 1:
			if x == 0:
				break
			x -= 1
		v = i
	print(v)


for _ in range(int(input())):
	(_, x) = map(int, input().split())
	n = set([*map(int, input().split())])
	i = 1
	while x > 0:
		if not i in n:
			n.add(i)
			x -= 1
		i += 1
	while True:
		if i in n:
			i += 1
		else:
			print(i - 1)
			break


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a = list(dict.fromkeys(a))
	b = [0] * len(a)
	flag = False
	for i in range(len(b)):
		if i == 0:
			b[i] = a[i] - 1
		else:
			b[i] = a[i] - a[i - 1] - 1
	for i in range(1, len(b)):
		b[i] += b[i - 1]
	for (i, each) in enumerate(b):
		if each > x:
			flag = True
			break
	if flag:
		if i - 1 >= 0:
			k = x - b[i - 1]
			val = a[i - 1] + k
		else:
			k = x
			val = k
	else:
		k = x - b[i]
		val = a[i] + k
	print(val)


t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().split())
	li = list(map(int, input().split()))
	i = 0
	li.sort()
	while 1:
		if x >= 0:
			i += 1
			if i not in li:
				x -= 1
			else:
				x = x
		elif x < 0:
			break
	if i not in li:
		i = i - 1
	else:
		i = i
	print(i)


t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	ans = [0 for i in range(100)]
	for i in range(n):
		ans[a[i] - 1] = 1
	for i in range(100):
		if x > 0:
			if ans[i] == 0:
				ans[i] += 1
				x -= 1
		else:
			break
	count = 0
	for i in range(100):
		if ans[i] != 1:
			count = i
			break
	if count == 0:
		print(100 + x)
	else:
		print(count)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = set(a)
	ans = 0
	c = x
	for i in range(1, n + x + 1):
		if i in b:
			ans += 1
		else:
			c -= 1
			if c < 0:
				break
			ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(set(a))
	y = int(max(a))
	l = [0] * y
	z = 0
	u = x
	for i in a:
		l[i - 1] = 1
	flag = 0
	for i in range(y):
		if l[i] == 0:
			u -= 1
			if u < 0:
				z = i
				flag = 1
				break
	if flag == 0:
		print(len(a) + x)
	else:
		print(z)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(set(map(int, input().split())))
	j = 1
	while 1:
		if j not in a and x == 0:
			break
		if j not in a:
			x -= 1
		j += 1
	print(j - 1)


def answer(l, m):
	count = 0
	for k in range(len(l)):
		if l[k]:
			continue
		count += 1
		if count == m + 1:
			return k
	else:
		return k + m - count + 1
for i in range(int(input())):
	(n, x) = map(int, input().split())
	a_list = list(map(int, input().split()))
	a_dedup = list(set(a_list))
	check = [0] * (max(a_dedup) + 1)
	for j in a_dedup:
		check[j - 1] = 1
	print(answer(check, x))


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = map(int, input().split())
	got = [0] * 300
	for aa in a:
		got[aa] = 1
	r = 1
	while True:
		if got[r] == 1:
			r += 1
			continue
		elif got[r] == 0 and x > 0:
			r += 1
			x -= 1
			continue
		elif got[r] == 0 and x == 0:
			print(r - 1)
			break


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = {int(a) for a in input().split()}
	a = list(a)
	a = sorted(a)
	temp = 0
	length = len(a)
	if a[0] > x:
		if a[0] is x + 1:
			pass
		else:
			ans = x
			temp = 1
	missing = a[0] - 1
	x = x - missing
	i = 0
	while temp is 0:
		if i is length - 1:
			ans = a[i] + x
			break
		elif x + 1 is a[i + 1] - a[i]:
			ans = a[i + 1]
			x = x - (a[i + 1] - a[i] - 1)
			i = i + 1
		elif x + 1 < a[i + 1] - a[i]:
			ans = a[i] + x
			break
		else:
			x = x - (a[i + 1] - a[i] - 1)
			i = i + 1
			ans = a[i]
	print(ans)


for _ in range(int(input())):
	temp = [int(o) for o in input().split()]
	n = temp[0]
	x = temp[1]
	a = [int(o) for o in input().split()]
	count = [0 for i in range(1011)]
	for key in a:
		count[key] = 1
	i = 1
	while x > 0:
		if count[i] is 0:
			count[i] = 1
			x -= 1
		i += 1
	i = 1
	while i < 1011:
		if count[i] is 0:
			break
		i += 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	r = 1
	while x:
		if r not in arr:
			x -= 1
		if x > 0:
			r += 1
	while r + 1 in arr:
		r += 1
	print(r)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	v = [False for _ in range(1000)]
	for a in arr:
		v[a] = True
	for i in range(1, 1000):
		if not v[i]:
			if x == 0:
				break
			x -= 1
	print(i - 1)


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	(n, x) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	a.sort()
	d = {}
	for i in a:
		d[i] = True
	for i in range(1, 210):
		if i not in d:
			x -= 1
			if x <= 0:
				ans = i
				break
	for j in range(i + 1, 210):
		if i + 1 in d:
			ans += 1
			i += 1
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = tuple(map(int, input().split()))
	a = set(map(int, input().split()))
	a = sorted(list(a))
	if 1 not in a and x > 0:
		x -= 1
	last_checked = 1
	for new in range(2, n + x + 2):
		if new in a:
			last_checked = new
			continue
		if x > 0:
			a.append(new)
			last_checked = new
			x -= 1
		else:
			break
	print(last_checked)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	i = 0
	while m > -1:
		i += 1
		if i not in l:
			m -= 1
	print(i - 1)


def main():
	n = int(input())
	for _ in range(n):
		(a, b) = input().split()
		(a, b) = (int(a), int(b))
		nos = set(map(int, input().split()))
		a = len(nos)
		predictedSum = a + b
		for i in range(1, predictedSum + 1):
			if i in nos:
				pass
			else:
				if b == 0:
					i = i - 1
					break
				b -= 1
		print(i)
main()


for ekbaar in range(1):
	for fall7stand8th in range(int(input())):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = [0] * (max(a) + 1)
		for _ in range(len(a)):
			b[a[_] - 1] = 1
		x = 0
		for _ in range(len(b)):
			if b[_] == 0 and m > 0:
				m -= 1
				b[_] = 1
			if m == 0:
				break
		if 0 in b:
			print(b.index(0))
		else:
			print(len(b) + m)


import sys
input = sys.stdin.readline
for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	while x > -1:
		i += 1
		if i not in a:
			x -= 1
	print(i - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	A = [int(j) for j in input().split()]
	A = set(A)
	j = 1
	while True:
		if j in A:
			j += 1
		else:
			if x == 0:
				break
			x -= 1
			j += 1
	print(j - 1)


for i in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	l = sorted(set([int(i) for i in input().split()]))
	j = 1
	while x:
		if j not in l:
			l += [j]
			x -= 1
		j += 1
	l = sorted(l)
	result = 0
	for i in range(len(l) - 1):
		if l[i] - l[i + 1] == -1:
			result += 1
		else:
			break
	print(result + 1)


t = int(input())
for i in range(t):
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	a = list(set(map(int, input().split())))
	y = x
	v = 0
	for i in range(1, max(a) + 1 + y):
		if i in a:
			v += 1
		elif x != 0:
			x -= 1
			v += 1
		else:
			break
	print(v)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = set(arr)
	i = 0
	while k > 0:
		i += 1
		if i not in s:
			k -= 1
			s.add(i)
	while i in s:
		i += 1
	print(i - 1)


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


def solve():
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	i = n + x
	while i >= 1:
		e = 0
		for j in range(1, i + 1):
			if j not in arr:
				e += 1
		if e <= x:
			print(i)
			return
		i -= 1
for ii in range(int(input())):
	solve()


from collections import defaultdict
from sys import stdin, stdout

def write(_s):
	stdout.write(_s)

def write_int(_s):
	stdout.write(str(_s))

def write_list(_l):
	stdout.write(''.join(_l))

def read():
	return stdin.readline().split(' ')

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

def read_int_l():
	return map(int, stdin.readline().split(' '))
t = readint()
while t:
	(n, x) = read_int_l()
	a = list(read_int_l())
	positions = [0] * 100
	for pos in a:
		positions[pos - 1] = 1
	for i in range(len(positions)):
		if positions[i] == 0:
			positions[i] = 1
			x -= 1
		if x == 0:
			break
	while i < len(positions) and positions[i] == 1:
		i += 1
	write_int(i + x)
	write('\n')
	t -= 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	freq = [0] * 300
	for elem in a:
		freq[elem - 1] += 1
	i = 0
	while x > 0:
		if freq[i] == 0:
			freq[i] = 1
			x -= 1
		i += 1
	ans = 0
	i = 0
	while i < 300 and freq[i] >= 1:
		ans += 1
		i += 1
	print(ans)


def solve(ax, x):
	table = [False] * 300
	table[0] = True
	for a in ax:
		table[a] = True
	cur_ind = 1
	for cur_ind in range(300):
		if not table[cur_ind]:
			table[cur_ind] = True
			x -= 1
		if x == 0:
			break
	while table[cur_ind]:
		cur_ind += 1
	return cur_ind - 1
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	ax = list(map(int, input().split()))
	print(solve(ax, x))


t = int(input())
for i in range(t):
	n_m = list(map(int, input().split()))
	n = n_m[0]
	x = n_m[1]
	a = list(map(int, input().split()))
	a.sort()
	flag = 0
	for j in range(n):
		if j == 0:
			diff = a[0] - 1
		else:
			diff = a[j] - a[j - 1] - 1
		if diff > 0 and x >= diff:
			x -= diff
		elif x == 0 and diff > 0:
			print(a[j - 1])
			flag = 1
			break
		elif diff > 0 and x < diff:
			if j == 0:
				print(x)
			else:
				print(a[j - 1] + x)
			flag = 1
			break
	if x > 0 and flag == 0:
		print(a[n - 1] + x)
	elif x == 0 and flag == 0:
		print(a[n - 1])


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	data = list(map(int, input().split()))
	for k in range(n + x, 0, -1):
		b = [i for i in range(1, k + 1)]
		s = [i for i in b if i not in data]
		if len(s) <= x:
			print(k)
			break


test = int(input())
for t in range(test):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set(a)
	ans = 0
	i = 1
	while x > 0 or i in s:
		if i in s:
			ans = i
			i += 1
		else:
			ans = i
			i += 1
			x -= 1
	print(ans)


import sys

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		nums = list(map(int, sys.stdin.readline().split()))
		numSet = set(nums)
		cnt = 0
		while True:
			if cnt + 1 in numSet:
				cnt += 1
				continue
			else:
				if x == 0:
					break
				x -= 1
				cnt += 1
		print(cnt)
	return
main()


query = int(input())
for _ in range(query):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	y0 = y
	v = 1
	while y0:
		p = False
		for i in a:
			if i == v:
				p = True
				break
		if not p:
			y0 -= 1
			a += [v]
		v += 1
	count = 1
	a.sort()
	for i in range(1, x + y):
		if a[i] - a[i - 1] == 1:
			count += 1
		elif a[i] - a[i - 1] >= 2:
			break
	print(count)


n = int(input())
while n:
	(a, b) = [int(i) for i in input().split(' ')]
	l = [int(i) for i in input().split(' ')]
	i = 0
	while b > 0:
		i = i + 1
		if i not in l:
			b = b - 1
	while i + 1 in l:
		i = i + 1
	print(i)
	n = n - 1


T = int(input())
for _ in range(T):
	(n, x) = [int(t) for t in input().split()]
	A = [int(t) for t in input().split()]
	A = list(set(A))
	A.sort()
	c = 1
	while not (x == 0 and c not in A):
		if len(A) != 0:
			if A[0] == c:
				A.pop(0)
			else:
				x -= 1
		else:
			x -= 1
		c += 1
	print(c - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	(s, p) = (input().split(), [0] * 202)
	for i in range(n):
		p[int(s[i])] = 1
	k = 1
	for i in range(x):
		while p[k] == 1:
			k = k + 1
		k = k + 1
	while p[k] == 1:
		k = k + 1
	print(k - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	ma = max(l) + x + n
	k = []
	for j in range(ma):
		k.append(0)
	for j in l:
		k[j - 1] = 1
	for i in range(ma):
		if k[i] != 1:
			k[i] = 1
			x -= 1
		if x == 0:
			break
	ans = k.index(0)
	print(ans)


def calc(x, a):
	v = 0
	while v + 1 in a:
		v += 1
	while x != 0:
		if v + 1 not in a:
			x -= 1
		v += 1
	while v + 1 in a:
		v += 1
	return v
t = int(input())
vs = []
for i in range(t):
	(n, x) = input().split()
	a = input().split()
	(n, x) = (int(n), int(x))
	a = [int(i) for i in a]
	vs.append(calc(x, a))
for v in vs:
	print(v)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = []
	i = 1
	while x > 0:
		if i in l:
			s.append(i)
		else:
			s.append(i)
			x = x - 1
		i = i + 1
	while i in l:
		s.append(i)
		i = i + 1
	print(len(s))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	l = list(map(int, input().split()))
	k = 0
	for num in range(1, 100 * (y * 100)):
		if k == y:
			p = num - 1
			break
		elif num not in l:
			l.append(num)
			k += 1
	for t in range(p, max(l) + 1):
		if t not in l:
			print(t - 1)
			break
	else:
		print(max(l))


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = set(list(map(int, input().split())))
	v = 1
	while x > 0:
		if v not in a:
			x -= 1
		v += 1
	while v in a:
		v += 1
	print(v - 1)


for _ in range(int(input())):
	(n, x) = (int(x) for x in input().split())
	a = sorted(set((int(i) for i in input().split())))
	ans = 0
	i = 0
	while x > 0 and i < len(a):
		if a[i] != ans + 1:
			x -= 1
		else:
			i += 1
		ans += 1
	while i < len(a):
		if a[i] == ans + 1:
			ans += 1
			i += 1
		else:
			break
	ans += x
	print(ans)


for nt in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	vis = [-1] * 100
	for i in range(n):
		vis[l[i] - 1] = 1
	i = 0
	while x != 0 and i < 100:
		if vis[i] == -1:
			x = x - 1
			vis[i] = 1
		i += 1
	if x == 0:
		if -1 in vis:
			for i in range(100):
				if vis[i] == -1:
					print(i)
					break
		else:
			print(100)
	else:
		print(100 + x)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	b = list(set([int(i) for i in input().split()]))
	x = 1
	while k != 0:
		if x not in b:
			k -= 1
		x += 1
	x -= 1
	while x + 1 in b:
		x += 1
	print(x)


def calculate():
	(n, x) = map(int, input().split())
	a = []
	inp = input()
	for n in inp.split():
		a.append(int(n))
	a.sort()
	curNumber = 1
	loopEnd = len(a)
	i = 0
	while i < loopEnd:
		if i == 0 and a[0] != 1 and (x > 0):
			a.insert(0, 1)
			loopEnd = loopEnd + 1
			curNumber = curNumber + 1
			x = x - 1
		if a[i] < curNumber:
			pass
		elif a[i] == curNumber:
			curNumber = curNumber + 1
		elif a[i] > curNumber and x > 0:
			a.insert(i, curNumber)
			loopEnd = loopEnd + 1
			curNumber = curNumber + 1
			x = x - 1
		i = i + 1
	if x > 0:
		print(curNumber - 1 + x)
	else:
		print(curNumber - 1)
times = int(input())
for i in range(times):
	calculate()


for _ in range(0, int(input())):
	nandx = list(map(int, input().split()))
	n = nandx[0]
	x = nandx[1]
	array = list(map(int, input().split()))
	array.sort()
	array = list(set(array))
	answer = 0
	i = 1
	c = 0
	answer = 0
	while True:
		while i in array:
			answer += 1
			i += 1
		if x == c:
			break
		c += 1
		answer += 1
		i += 1
	print(answer)


Tests = int(input())
while Tests > 0:
	Tests -= 1
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	l = []
	for i in range(0, 204):
		l.append(0)
	for i in A:
		l[i] = 1
	st = 0
	for i in range(1, len(l)):
		if x and l[i] == 0:
			x -= 1
			l[i] = 1
		if l[i]:
			st = i
		else:
			break
	print(st)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = [0] * 101
	lst = input().split()
	for a_i in lst:
		a[int(a_i)] = 1
	for (tmp_ind, a_i) in enumerate(a[1:]):
		if a_i == 1:
			ind = tmp_ind + 1
			continue
		if x != 0:
			x -= 1
			ind = tmp_ind + 1
			continue
		else:
			break
	print(ind + x)


from collections import defaultdict
for _ in range(int(input())):
	(N, K) = map(int, input().split())
	L = list(map(int, input().split()))
	Hash = defaultdict(lambda : 0)
	for i in L:
		Hash[i] = 1
	distinct = 0
	for i in range(1, 300):
		if Hash[i] == 1:
			distinct += 1
		if i - distinct == K:
			Ans = i
		elif i - distinct > K:
			Ans = i - 1
			break
	print(Ans)


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	ans = 1
	while x > 0:
		while ans in a:
			ans += 1
		x -= 1
		ans += 1
		while ans in a:
			ans += 1
	print(ans - 1)


def solved():
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	k = 0
	while m > 0:
		k += 1
		if k not in a:
			m -= 1
	if k + 1 in a:
		k += 1
		while k in a:
			k += 1
		k -= 1
	print(k)
n = int(input())
for i in range(n):
	solved()


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	(n, x) = I()
	a = list(I())
	b = [0] * 202
	for i in a:
		b[i] = 1
	v = 1
	while x > 0 or b[v] > 0:
		if b[v] == 0:
			x -= 1
		v += 1
	print(v - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(set(map(int, input().split())))
	arr.sort()
	check = [False] * 222
	for i in range(len(arr)):
		check[arr[i]] = True
	ans = 1
	while x > 0:
		if check[ans]:
			ans += 1
		else:
			x -= 1
			check[ans] = True
			ans += 1
	ans = 0
	for i in range(1, 222):
		if check[i]:
			ans += 1
		else:
			break
	print(ans)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

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

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	(n, x) = mi()
	arr = set(li())
	i = 0
	p = 1
	while i < x or p in arr:
		if p in arr:
			p += 1
		else:
			arr.add(p)
			p += 1
			i += 1
	print(p - 1)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = set(map(int, input().split()))
	i = 1
	while i in l or x > 0:
		if i not in l:
			x -= 1
		i += 1
	print(i - 1)


import sys
from math import sqrt, floor
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().split()))

def a():
	ans = ''
	for _ in range(int(inp())):
		(n, x) = read()
		arr = sorted(list(set(read())))
		n = len(arr)
		i = 0
		while i < n and arr[i] <= x + 1:
			x += 1
			i += 1
		ans += str(x) + '\n'
	print(ans)
a()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 1
	j = x
	while i <= x + n + 1:
		if i in a:
			pass
		elif j != 0:
			j -= 1
		else:
			break
		i += 1
	print(i - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	i = 1
	while True:
		if i not in a:
			x -= 1
			if x == 0:
				break
		i += 1
	while i + 1 in a:
		i += 1
	print(i)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	curr = 0
	while len(a) > 0:
		if a[0] == curr + 1:
			while len(a) > 0 and a[0] == curr + 1:
				a.pop(0)
		elif a[0] != curr + 1 and x > 0:
			x -= 1
		elif x <= 0:
			break
		curr += 1
	print(curr + x)


import sys
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	l = [int(i + 1) for i in range(300)]
	while x > 0:
		x -= 1
		a = list(set(a))
		a.sort()
		for i in l:
			if i not in a:
				a.append(i)
				break
	a.sort()
	for i in l:
		if i not in a:
			ans = i
			break
	print(ans - 1)


import sys
check = [0 for i in range(1005)]
check1 = [0 for i in range(1005)]
t = int(input())
for z in range(1, t + 1):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	for i in a:
		check[i] = 1
	num = 1
	for i in range(1, x + 1):
		while check[num] == 1:
			num += 1
		check[num] = 1
		a.append(num)
	a.sort()
	b = []
	res = 1
	for i in a:
		if check1[i] == 0:
			check1[i] = 1
			b.append(i)
	for i in range(0, len(b) - 1):
		if b[i] + 1 == b[i + 1]:
			res += 1
		else:
			break
	print(res)
	for i in range(0, 1001):
		check[i] = 0
		check1[i] = 0


n = int(input())
for i in range(0, n):
	o = input().rstrip().split(' ')
	p = input().rstrip().split(' ')
	p.sort(key=int)
	if 1:
		k = int(o[1])
		for i in range(1, 10000000):
			if str(i) in p:
				continue
			else:
				k -= 1
			if k == 0:
				V = i
			if k < 0:
				V = i - 1
				break
		print(V)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	mx = max(l)
	i = 1
	while x > 0:
		if i not in l:
			x -= 1
		i += 1
	while True:
		if i not in l:
			break
		else:
			i += 1
	print(i - 1)


import collections
import itertools
from functools import lru_cache
import sys
import math

def helper():
	pass

def solve():
	(n, k) = map(int, input().split(' '))
	nums = set(map(int, input().split(' ')))
	rank = 0
	for i in range(1, max(nums) + 1):
		if i in nums:
			rank += 1
		elif k > 0:
			rank += 1
			k -= 1
		else:
			print(rank)
			return
	while k > 0:
		rank += 1
		k -= 1
	print(rank)
t = int(input())
for _ in range(t):
	solve()


from sys import stdin

def func():
	return
for _ in range(int(stdin.readline())):
	(n, x) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	val = 1
	while x > 0:
		if val in arr:
			val += 1
		else:
			arr.append(val)
			x -= 1
	arr = sorted(list(set(arr)))
	cond = True
	for i in range(len(arr)):
		if arr[i] != i + 1:
			cond = False
			break
	if cond == False:
		print(i)
	else:
		print(i + 1)


import sys
from collections import defaultdict as dc
import math
from bisect import bisect, bisect_left, bisect_right
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	t = dc(int)
	l = list(map(int, input().split()))
	for i in l:
		t[i] = 1
	i = 1
	while i <= 1000:
		if t[i] == 1:
			i += 1
		elif x == 0:
			break
		else:
			x -= 1
			i += 1
	print(i - 1)


def solve():
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	for i in range(1, max(lst) + k + 1):
		if i not in lst:
			lst.append(i)
			k -= 1
		if k == 0:
			break
	ans = [i for i in range(1, max(lst) + k + 1)]
	lst = list(set(lst))
	lst.sort()
	cur = 0
	for i in range(len(lst)):
		if lst[i] == ans[i]:
			cur += 1
		else:
			break
	print(cur)
t = int(input())
for i in range(t):
	solve()


def solve():
	(n, x) = map(int, input().split())
	a = [0] * 210
	l = [int(y) for y in input().split()]
	for k in l:
		a[k - 1] += 1
	for i in range(len(a)):
		if a[i] == 0:
			a[i] += 1
			x -= 1
			if x == 0:
				break
	print(a.index(0))
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	m = list(map(int, input().split()))
	l = []
	i = 1
	while x > 0:
		if i in m:
			l.append(i)
		else:
			l.append(i)
			x = x - 1
		i += 1
	j = 0
	while j < len(m):
		if l[len(l) - 1] + 1 in m:
			l.append(l[len(l) - 1] + 1)
		j += 1
	print(l[len(l) - 1])


for i in range(int(input())):
	(a, b) = map(int, input().split())
	l = sorted(list(set(map(int, input().split()))))
	r = 0
	for i in range(1, l[-1] + b + 1):
		if i in l:
			r += 1
		elif b == 0:
			break
		else:
			r += 1
			b -= 1
	print(r)


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a = list(set(a))
	a.sort()
	for i in range(1, 1000):
		if i not in a:
			if x == 0:
				print(i - 1)
				f = 1
				break
			x = x - 1


t = int(input())
for q in range(t):
	(n, c) = map(int, input().split())
	places = list(map(int, input().split()))
	places = list(set(places))
	places.sort()
	missing = {}
	for x in range(places[-1] + c, 0, -1):
		missing[x] = [y not in places for y in range(1, x + 1)]
		if missing[x].count(True) <= c:
			print(x)
			break


import itertools
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	p = set(map(int, input().split()))
	r = 0
	for j in itertools.count(1):
		if j in p:
			r += 1
			continue
		else:
			if x <= 0:
				break
			x -= 1
			r += 1
	print(r)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a = list(dict.fromkeys(a))
	optimal = list((z for z in range(1, n + x + 1)))
	for i in range(len(optimal)):
		if x == 0:
			break
		if optimal[i] not in a:
			a.append(optimal[i])
			x -= 1
	a.sort()
	a = list(dict.fromkeys(a))
	for i in range(len(a)):
		try:
			if a[i + 1] - a[i] > 1:
				print(a[i])
				break
		except:
			print(a[i])


for i in range(int(input())):
	(n, x) = map(int, input().split())
	s = set(list(map(int, input().split())))
	for j in range(1, 233):
		if j not in s:
			if x == 0:
				print(j - 1)
				break
			else:
				x -= 1


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	ans = 0
	count = 0
	while True:
		if count >= x:
			break
		ans += 1
		if ans not in arr:
			count += 1
	while True:
		if ans + 1 in arr:
			ans += 1
		else:
			break
	print(ans)


for _ in range(int(input())):
	(lens, x) = [int(x) for x in input().split()]
	rounds = [int(x) for x in input().split()]
	to_check = 1
	while x > -1:
		if to_check not in rounds:
			x -= 1
		to_check += 1
	print(to_check - 2)


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
t = 1
t = int(input())
for _ in range(t):
	(n, x) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	count = defaultdict(lambda : 0)
	for i in a:
		count[i] += 1
	ans = 0
	for i in range(1, 1001):
		if i not in count:
			x -= 1
		ans = i
		if x == -1:
			ans = i - 1
			break
	print(ans)


t = int(input())
ans = []
for _ in range(t):
	(n, x) = [int(y) for y in input().split()]
	s = set((int(y) for y in input().split()))
	c = 1
	while True:
		if c not in s:
			if x == 0:
				c -= 1
				break
			x -= 1
		c += 1
	ans.append(str(c))
print('\n'.join(ans))


n_tests = int(input())
for i in range(1, n_tests * 2 + 1, 2):
	(n, x) = map(int, input().split(' '))
	places = list(set(map(int, input().split(' '))))
	places.sort()
	it = iter(places)
	curr = next(it)
	v = 1
	if v != curr:
		x -= 1
	while True:
		try:
			diff = curr - v
			if diff == 1:
				v += 1
				curr = next(it)
				continue
			elif diff == 0:
				curr = next(it)
				continue
			elif diff != 1 and x != 0:
				v += 1
				x -= 1
				continue
			if x == 0:
				break
		except StopIteration:
			if x != 0:
				v += x
			break
	print(v)


def solve():
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	ans = 0
	while x > 0:
		ans += 1
		if ans not in a:
			x -= 1
	while ans + 1 in a:
		ans += 1
	print(ans)
t = int(input())
for _ in range(t):
	solve()


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, x) = list(map(int, stdin.readline().split()))
	a = sorted(map(int, stdin.readline().split()))
	v = min(a[0] - 1, x)
	x -= v
	res = v
	i = 0
	while i < n:
		if a[i] <= res + 1:
			res = a[i]
			i += 1
			continue
		if x == 0:
			break
		v = min(a[i] - res - 1, x)
		x -= v
		res += v
	res += x
	print(res)


import math, sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, x) = map(int, sys.stdin.readline().split())
	l = list(map(int, sys.stdin.readline().split()))
	a = [0] * 1000
	for i in range(n):
		a[l[i]] += 1
	for i in range(1, 1000):
		if x == 0:
			break
		elif a[i] == 0 and x > 0:
			a[i] = 1
			x -= 1
	for i in range(1, 1000):
		if a[i] != 0 and a[i + 1] == 0:
			print(i)
			break


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	d = [0] * 202
	for j in a:
		d[j] = 1
	for j in range(1, 202):
		if d[j] == 0 and x:
			d[j] = 1
			x -= 1
	for j in range(1, 202):
		if d[j] == 0:
			print(j - 1)
			break


t = int(input())
for tt in range(t):
	nx = input().split(' ')
	n = int(nx[0])
	x = int(nx[1])
	a = list(map(int, input().split(' ')))
	ua = list(set(list(a)))
	dx = int(x)
	i = 1
	while dx > 0:
		if ua.count(i) == 0:
			ua.append(i)
			dx -= 1
		i += 1
	i -= 1
	while ua.count(i) != 0:
		i += 1
	print(i - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	v = 0
	i = 1
	while x >= 0:
		if i in arr:
			v += 1
			i += 1
		else:
			i += 1
			x -= 1
			v += 1
	print(v - 1)


t = int(input())
for case_num in range(t):
	(n, x) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	s = set(a)
	ans = 1
	while x >= 0:
		if not ans in s:
			if x == 0:
				ans -= 1
				break
			x -= 1
		ans += 1
	print(ans)


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	visited = [False] * 204
	for i in a:
		visited[i] = True
	i = 1
	while x >= 0 and i < 204:
		if visited[i] == False:
			x -= 1
			visited[i] = True
		i += 1
	print(i - 2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	arr.insert(0, 0)
	arr.sort()
	s = set(arr)
	(i, c, pre) = (0, 0, 0)
	while x > 0:
		if pre + 1 not in s:
			x = x - 1
		s.add(pre + 1)
		pre = pre + 1
		c = c + 1
	while c + 1 in s:
		c = c + 1
	print(c)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	count = 0
	i = 1
	while i <= x:
		if i in a:
			x += 1
		else:
			a.append(i)
		i += 1
	a.sort()
	v = 0
	i = 0
	while i < len(a):
		if i + 1 not in a:
			break
		else:
			v += 1
		i += 1
	print(v)


import sys
from collections import Counter

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, K) = MAP()
	A = LIST()
	S = set(A)
	i = 1
	while 1:
		if i not in S:
			if K == 0:
				print(i - 1)
				break
			else:
				K -= 1
		i += 1


import math
t = int(input())
while t > 0:
	t = t - 1
	nx = list(input().split())
	n = int(nx[0])
	x = int(nx[1])
	mapa = {}
	for i in range(1, 202):
		mapa[int(i)] = int(0)
	tab = list(input().split())
	for i in tab:
		mapa[int(i)] = 1
	licz = 0
	for i in range(1, 202):
		if mapa[i] == 0:
			licz = licz + 1
		if licz > x:
			print(i - 1)
			break


tests = int(input())
for _ in range(tests):
	(n, essais) = [int(x) for x in input().split()]
	places = [int(x) for x in input().split()]
	places = set(places)
	indice = 0
	suite = 1
	while indice < essais:
		if suite not in places:
			indice += 1
			places.add(suite)
		suite += 1
	for i in range(1, max(places) + 2):
		if i not in places:
			break
	print(i - 1)


t = int(input())
for i in range(t):
	(_, x) = map(int, input().split())
	an = sorted(set(map(int, input().split())))
	a_max = 0
	for a in an:
		diff = a - a_max - 1
		if diff > 0:
			if diff <= x:
				x = x - diff
				a_max = a
			else:
				break
		else:
			a_max = a
	print(a_max + x)


import sys
import math

def scan(input_type='int'):
	if input_type == 'int':
		return list(map(int, sys.stdin.readline().strip().split()))
	else:
		return list(map(str, sys.stdin.readline().strip()))

def solution():
	for _ in range(int(input())):
		(n, x) = scan()
		a = scan()
		b = [0] * (max(a) + 1)
		for i in a:
			b[i] = 1
		m = len(b)
		i = 1
		d = 0
		while x > 0:
			if i < m:
				if b[i] == 0:
					x -= 1
				d = i
				i += 1
			else:
				d += 1
				x -= 1
		if i < m:
			while b[i] != 0:
				d = i
				i += 1
				if i == m:
					break
		print(d)
solution()


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a = list(set(a))
	a.append(0)
	a.append(1000)
	a.sort()
	c = 0
	for i in range(1, len(a)):
		d = a[i] - a[i - 1] - 1
		if d == 0:
			c = a[i]
		elif d <= x:
			x -= d
			c = a[i]
		else:
			c = a[i - 1] + x
			break
	print(c)


def solve():
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = set()
	for a in arr:
		s.add(a)
	c = 0
	for i in range(1, 301):
		if i not in s:
			c += 1
		if c > x:
			break
	print(i - 1)
t = int(input())
while t > 0:
	solve()
	t -= 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	li = list(map(int, input().split()))
	li = list(set(li))
	li.sort()
	i = 0
	while x > -1:
		i += 1
		if i not in li:
			x -= 1
	print(i - 1)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

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))
from types import GeneratorType

def iterative(f, stack=[]):

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

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 nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

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 gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def YES():
	print('YES')

def NO():
	print('NO')

def Yes():
	print('Yes')

def No():
	print('No')
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

def solve():
	(n, x) = sep()
	ar = set(sorted(lis()))
	c = 0
	for i in range(1, 2000):
		if i not in ar:
			c += 1
		if c > x:
			print(i - 1)
			break
testcase(int(inp()))


t = int(input())
for j in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(sorted(list(map(int, input().split()))))
	j = 0
	for i in range(1, 300):
		if i in a:
			j += 1
		elif x >= 1:
			j += 1
			x -= 1
		else:
			break
	print(j)


def binarySearch(arr, l, x):
	for i in range(l):
		if arr[i] == x:
			return i
	return -1
t = int(input())
for i in range(t):
	num1 = list(map(int, input().split()))
	num2 = list(map(int, input().split()))
	num3 = [0 for i in range(250)]
	num4 = sorted(num2, reverse=False)
	z = len(num4)
	num5 = [num4[0]]
	for i in range(z - 1):
		if num4[i] == num4[i + 1]:
			continue
		else:
			num5.append(num4[i + 1])
	x = len(num5)
	s = 0
	for i in range(0, len(num3)):
		if binarySearch(num5, x, i + 1) == -1:
			num3[i] = i + 1
			s += 1
		elif binarySearch(num5, x, i + 1) != -1:
			num3[i] = num5[binarySearch(num5, x, i + 1)]
		if s > num1[1]:
			print(num3.index(0) - 1)
			break
		else:
			continue


kl = int(input())
for l in range(kl):
	(n, x) = map(int, input().split())
	b = {int(i) for i in input().split()}
	a = list(b)
	a.sort()
	a = [0] + a
	k = 0
	pr = 1
	for i in range(len(a) - 1):
		t = a[i + 1] - a[i] - 1
		if t > x:
			rz = a[i] + x
			pr = 0
			break
		x = x - t
	if pr:
		print(a[len(a) - 1] + x)
	else:
		print(rz)


def solution():
	for _ in range(int(input())):
		(n, x) = [int(i) for i in input().split()]
		arr = sorted(list({int(i) for i in input().split()}))
		current = 1
		for i in arr:
			if i == current:
				current += 1
			elif i - current > x:
				print(current + x - 1)
				break
			else:
				x -= i - current
				current = i + 1
		else:
			print(arr[-1] + x)
solution()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr1 = list(set(arr))
	arr1.sort()
	for i in arr1:
		if i <= m + 1:
			m = m + 1
	print(m)


import sys
import random
from math import log2, log, ceil
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

def primefs(n):
	if n == 1:
		return 1
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]
spf_sieve()

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, x) = int_array()
	a = int_array()
	this = [0] * 205
	for i in a:
		this[i] = 1
	for i in range(1, len(this)):
		if x == 0:
			break
		if this[i] == 0:
			this[i] = 1
			x -= 1
	for i in range(1, len(this)):
		if this[i] == 0:
			ans = i - 1
			break
	print(ans)


t = int(input())
for tt in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	ptr = 0
	v = 0
	cnt = x
	for i in range(1, 100000):
		while ptr < n and l[ptr] < i:
			ptr += 1
		if ptr == len(l):
			if cnt == 0:
				break
			v += 1
			cnt -= 1
			continue
		if l[ptr] == i:
			v += 1
		else:
			if cnt == 0:
				break
			v += 1
			cnt -= 1
	print(v)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	for j in range(1, 2000):
		if j in a:
			continue
		elif x > 0:
			x -= 1
		else:
			print(j - 1)
			break


a = int(input())
for i in range(a):
	s = set(range(2000))
	(n, x) = map(int, input().split())
	j = list(map(int, input().split()))
	for k in j:
		if k in s:
			s.remove(k)
	ii = list(s)
	ii.sort()
	print(ii[x + 1] - 1)


q = int(input())
for _ in range(q):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	i = 1
	while x > 0 or i in a:
		if i not in a:
			x -= 1
		i += 1
	print(i - 1)


def f(n, x, l):
	a = 0
	for i in range(1, x + n + 1):
		if i not in l:
			a += 1
			if x == a:
				for j in range(i + 1, n + x + 1):
					if j not in l:
						return j - 1
				return n + x
	return n + x
for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	print(f(n, x, l))


ans = []
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	u1 = list(map(int, input().split()))
	u1.sort()
	u = []
	u.append(u1[0])
	for i in range(1, n):
		if u1[i] != u1[i - 1]:
			u.append(u1[i])
	n = len(u)
	i = 1
	if x >= u[0] - 1:
		r = u[0]
		x -= u[0] - 1
	else:
		r = 0
	while i < n:
		if x < u[i] - u[i - 1] - 1:
			break
		x -= u[i] - u[i - 1] - 1
		r = u[i]
		i += 1
	if x > 0:
		r += x
	ans.append(r)
print('\n'.join(map(str, ans)))


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	i = 1
	while True:
		if i in lst:
			pass
		elif i not in lst and x > 0:
			x = x - 1
		else:
			print(i - 1)
			break
		i += 1


t = int(input())
while t > 0:
	t = t - 1
	p = input().split()
	n = int(p[0])
	x = int(p[1])
	a = input().split()
	temp = [0] * (1000 + x)
	for i in a:
		temp[int(i) - 1] = 1
	temp2 = x
	for i in range(n + x + 1):
		if temp2 != 0:
			if temp[i] == 0:
				temp[i] = 1
				temp2 = temp2 - 1
	for i in range(n + x + 1):
		if temp[i] == 0:
			break
	print(i)


def ranks(arr, x):
	s = list(set(arr))
	m = 1
	l = []
	while x != 0:
		if m not in s:
			l.append(m)
			x -= 1
		else:
			l.append(m)
		m += 1
	l.sort()
	s.sort()
	for i in s:
		if i == l[-1] + 1:
			l.append(i)
	l.sort()
	return l[-1]
t = int(input())
for _ in range(t):
	nx = input().split()
	n = int(nx[0])
	x = int(nx[1])
	arr = list(map(int, input().split()))
	print(ranks(arr, x))


import sys

def solve(ans):
	(n, x) = [int(x) for x in input().split()]
	li = [int(x) for x in input().split()]
	maxm = sys.maxsize
	for i in range(1, maxm + 1):
		if x != 0 and i not in li:
			x -= 1
		elif x == 0 and i not in li:
			break
		note = i
	ans.append(note)
	return
n = int(input())
ans = []
for i in range(n):
	solve(ans)
for ele in ans:
	print(ele)


T = int(input())
for case in range(1, T + 1):
	(n, x) = map(int, input().split())
	s = set(map(int, input().split()))
	element = 1
	while x > 0:
		if element in s:
			element += 1
		else:
			s.add(element)
			element += 1
			x -= 1
	i = 1
	while i in s:
		i += 1
	print(i - 1)


for test in range(int(input())):
	(n, x) = map(int, input().split())
	ans = list(map(int, input().split()))
	ans = list(set(ans))
	ans.sort()
	flag = 0
	for i in range(len(ans) - 1, -1, -1):
		ele = ans[i]
		temp = ele - i - 1
		if x - temp >= 0:
			flag = 1
			print(ele + x - temp)
			break
	if flag == 0:
		print(x)


t = int(input())
for w in range(t):
	(n, x) = [int(i) for i in input().split()]
	values = [int(i) for i in input().split()]
	values.append(0)
	values.sort()
	tam = len(values)
	i = 1
	v = values[0]
	while i < tam and x >= values[i] - values[i - 1] - 1:
		if values[i] - values[i - 1] > 1:
			x -= values[i] - values[i - 1] - 1
		v = values[i]
		i += 1
	print(v + x)


task_number = int(input())
for _ in range(task_number):
	(n, x) = map(int, input().split())
	existing_places = {int(i) for i in input().split()}
	v = 0
	s = 0
	for i in range(1, x + n + 1):
		if i in existing_places:
			v += 1
		else:
			if s == x:
				break
			v += 1
			s += 1
	print(v)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, x) = inputnums()
	a = inputlist()
	a.sort()
	if a[0] <= x + 1:
		x += 1
	for i in range(1, n):
		if a[i] != a[i - 1]:
			if a[i] <= x:
				x += 1
			elif a[i] == x + 1:
				x += 1
			else:
				break
	print(x)


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
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 test():
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in range(1, n + x + 1):
		if i not in l and x > 0:
			l.append(i)
			x -= 1
	c = 0
	l = sorted(set(l))
	for i in range(len(l)):
		if i + 1 == l[i]:
			c += 1
	return c
t = int(input())
for _ in range(t):
	print(test())


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	list_num = sorted(set(list(map(int, input().split()))))
	for i in list_num:
		if i <= x:
			x += 1
		elif i == x + 1:
			x += 1
	print(x)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = set(l)
	j = 1
	for i in range(1, x + 1):
		while j in s:
			j += 1
		j += 1
	while True:
		if j in s:
			j += 1
		else:
			break
	print(j - 1)


t = int(input())
while t > 0:
	(n, x) = [int(x) for x in input().split(' ')]
	arr = [int(x) for x in input().split(' ')]
	mark = [0] * 102
	for num in arr:
		mark[num] = 1
	ans = -1
	for i in range(1, 205):
		countcur = 0
		for j in range(1, min(i + 1, 101)):
			if mark[j] == 1:
				countcur += 1
		if countcur + x >= i:
			ans = i
	print(ans)
	t -= 1


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(set(map(int, input().split()))))
	l = len(a)
	m1 = -1
	mx2 = max(a)
	if l == mx2:
		print(mx2 + x)
	else:
		comp = mx2 - l
		if comp >= x:
			mx = mx2
		else:
			mx = mx2 + x - comp
		while True:
			if l + x >= mx:
				print(mx)
				break
			else:
				try:
					a.remove(mx)
				except:
					pass
				finally:
					l = len(a)
					mx -= 1


testCases = int(input())
answers = []
for j in range(testCases):
	xx = list(map(int, input().split()))
	x = xx[1]
	arr = list(map(int, input().split()))
	init = list(range(1, max(arr) + 1))
	a = []
	for i in range(0, max(arr)):
		if init[i] in arr:
			if init[i] not in a:
				a.append(init[i])
			pass
		elif x > 0:
			x = x - 1
			a.append(init[i])
		elif x == 0:
			break
	curr = a[len(a) - 1] + 1
	while curr in arr:
		curr = curr + 1
	ans = curr - 1 + x
	answers.append(ans)
for i in answers:
	print(i)


test = int(input())
for t in range(test):
	(n, x) = map(int, input().split())
	list = [int(i) for i in input().split()]
	list.sort()
	dp = [x for i in range(n)]
	for i in range(n):
		if i == 0:
			if 1 + x >= list[i]:
				dp[i] += 1
		elif list[i] != list[i - 1]:
			dp[i] = dp[i - 1] + 1
			if dp[i] < list[i]:
				dp[i] = dp[i - 1]
		else:
			dp[i] = dp[i - 1]
	print(dp[n - 1])


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = [0] * 201
	ans = 0
	for i in range(n):
		l1[l[i]] = 1
	for i in range(1, 201):
		if l1[i] == 0:
			if x == 0:
				break
			else:
				x -= 1
				ans += 1
		else:
			ans += 1
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = set(l)
	m = max(s)
	va = -1
	for i in range(1, m + 1):
		if i not in s:
			if x > 0:
				x -= 1
			else:
				va = i
				break
	if va == -1:
		ans = m
	else:
		ans = va - 1
	if x > 0:
		ans = ans + x
	print(ans)


for _ in range(int(input())):
	(n, kk) = map(int, input().split())
	l = [int(x) for x in input().split()]
	k = []
	j = 1
	while kk > 0:
		if j not in l:
			k.append(j)
			kk = kk - 1
		j = j + 1
	ii = 1
	p = max(k)
	while 1:
		if p + ii in l:
			ans = 0
			ans = p + ii
			ii = ii + 1
			k.append(ans)
		else:
			break
	print(max(k))


def main_function():
	for i in range(int(input())):
		(n, x) = list(map(int, input().split(' ')))
		A = list(map(int, input().split()))
		ans = [False] * 201
		for el in A:
			ans[el - 1] = True
		k = 0
		while x > 0 or ans[k]:
			if not ans[k]:
				x -= 1
			k += 1
		print(k)
main_function()


import sys
read = sys.stdin.buffer.readline
for _ in range(int(read())):
	(n, x) = map(int, read().split())
	a = list(map(int, read().split()))
	vis = [0] * max(n + x + 1, max(a) + 1)
	for el in a:
		vis[el - 1] = 1
	ans = 1
	for i in range(1, len(vis)):
		vis[i] = vis[i - 1] + vis[i]
		if i + 1 - vis[i] <= x:
			ans = i + 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	visited = {}
	for i in l:
		visited[i] = True
	i = 1
	while x > 0:
		if i not in visited:
			visited[i] = True
			x -= 1
		i += 1
	while i in visited and visited[i]:
		i += 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [False] * 101
	for i in a:
		l[i] = True
	count = 0
	for i in range(1, 101):
		if l[i] == False:
			if x > 0:
				x -= 1
			else:
				break
		count += 1
	if x > 0:
		print(count + x)
	else:
		print(count)


a = int(input())
x = int(0)
while x < a:
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	tp = int(0)
	j = y = int(1)
	while b[1] != -1:
		v = int(0)
		j = tp
		while v < b[0]:
			if y == c[v]:
				tp = tp + 1
				y = y + 1
			v = v + 1
		if j == tp:
			b[1] = b[1] - 1
			tp = tp + 1
			y = y + 1
	print(tp - 1)
	x = x + 1


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().strip().split()))[:n]
	a.sort()
	p = 1
	while x > 0:
		if p not in a:
			a.append(p)
			x -= 1
		p += 1
	a = set(a)
	for i in range(1, len(a) + 1):
		if i not in a:
			print(i - 1)
			break
	else:
		print(max(a))


for _ in range(int(input())):
	(n, x) = map(int, input().strip().split())
	l = list(map(int, input().strip().split()))
	s = [0] * (max(l) + n + x)
	for i in l:
		s[i - 1] = 1
	for i in range(len(s)):
		if s[i] != 1:
			s[i] = 1
			x -= 1
		if x == 0:
			break
	v = s.index(0)
	print(v)


T = int(input())
for i in range(T):
	(n, x) = map(int, input().split())
	B = list(map(int, input().split()))
	B.sort()
	k = B[0]
	C = [k]
	for j in range(len(B) - 1):
		if B[j + 1] == k:
			continue
		else:
			C.append(B[j + 1])
			k = B[j + 1]
	sumn = C[0] - 1
	sumo = 0
	ind = 0
	extra = 0
	C.append(500)
	for j in range(1, len(C)):
		sumo = sumn
		sumn += C[j] - C[j - 1] - 1
		if sumn > x:
			if j == 1:
				break
			else:
				ind = j
				extra = x - sumo
				break
	if ind == 0:
		if sumo > x:
			ans = x
		else:
			ans = x + 1
	else:
		ans = C[ind - 1] + extra
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	aa = list(map(int, input().split()))
	ss = set()
	tot = x
	for i in aa:
		ss.add(i)
	ans = 0
	for i in range(1, 300):
		if i not in ss:
			tot -= 1
			if tot < 0:
				ans = i - 1
				break
	print(ans)


t = int(input())
while t:
	line = input().split()
	(n, x) = (int(line[0]), int(line[1]))
	a = input().split()
	a = list(set([int(x) for x in a]))
	a.sort()
	v = 0
	for i in range(len(a)):
		if x >= a[i] - v - 1:
			x -= a[i] - v - 1
			v = a[i]
		else:
			v += x
			x = 0
			break
	if x > 0:
		v += x
	print(v)
	t -= 1


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	places = 0
	for i in range(1, 1000):
		if i in a:
			places += 1
		elif x > 0:
			x -= 1
			places += 1
		else:
			print(places)
			break


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(set(a))
	b.sort()
	val = x
	for i in range(len(b)):
		if val >= b[i]:
			val += 1
		elif b[i] - val == 1:
			val += 1
		else:
			break
	print(val)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	coun = 0
	for i in range(1, 10 ** 6):
		if i in a:
			continue
		else:
			coun += 1
		if coun == x + 1:
			print(i - 1)
			break


import sys
inp = sys.stdin
arr = []

def found(num):
	for i in range(len(arr)):
		if arr[i] == num:
			return True
	return False
t = int(inp.readline())
ans = []
for i in range(t):
	(a, x) = map(int, inp.readline().split())
	arr = list(map(int, inp.readline().split()))
	for j in range(1, 12345):
		if found(j) == False:
			x -= 1
			if x < 0:
				ans.append(j - 1)
				break
for i in ans:
	print(i)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted([int(i) for i in input().split()])
	for i in range(1, 500):
		if i not in a:
			x -= 1
			a.append(i)
		if x == 0:
			break
	for i in range(1, 500):
		if i not in a:
			break
	print(i - 1)


t = int(input())
for l in range(t):
	(si, st) = map(int, input().split())
	inp = list(map(int, input().split()))
	arr = [0] * (max(inp) + 1)
	arr[0] = 1
	for ele in inp:
		arr[ele] = 1
	sum = ans = 0
	for i in range(len(arr)):
		if arr[i] == 0:
			sum += 1
			arr[i] = 1
		if sum == st:
			break
	if sum != st:
		for i in range(st - sum):
			arr.append(1)
	for i in range(len(arr)):
		if arr[i] == 0:
			ans = i - 1
			break
	if ans == 0:
		print(len(arr) - 1)
	else:
		print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	sp = list(map(int, input().split()))
	d = [0] * max(sp)
	for j in sp:
		d[j - 1] = 1
	f = min(x, d.count(0))
	prosh = 0
	for j in range(f):
		h = d[prosh:].index(0)
		d[prosh + h] = 1
		prosh += h
	if 0 in d:
		print(d.index(0))
	else:
		print(x + len(d) - f)


def solver(x, a):
	for j in range(len(contests)):
		if contests[j] in a:
			pass
		else:
			x -= 1
			a.append(contests[j])
			if x == 0:
				for qwe in range(len(contests)):
					if contests[qwe] not in a:
						return contests[qwe - 1]
				else:
					return contests[-1]
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	contests = list(range(1, n + x + 1))
	a = list(map(int, input().split()))
	print(solver(x, a))


def solve():
	(N, X) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr = set(arr)
	ind = 1
	while True:
		if ind in arr:
			ind += 1
		elif X > 0:
			ind += 1
			X -= 1
		else:
			break
	print(ind - 1)
T = int(input())
for t in range(T):
	solve()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = sorted(set(list(map(int, input().split()))))
	for j in l:
		if j <= x + 1:
			x += 1
	print(x)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, X) = [int(x) for x in input().split()]
		A = [int(x) for x in input().split()]
		Aset = set(A)
		ans = 0
		for i in range(1, 2):
			tmp = X
			itmp = i
			anstmp = 0
			while tmp > 0:
				if itmp in Aset:
					itmp += 1
					anstmp += 1
					continue
				else:
					itmp += 1
					tmp -= 1
					anstmp += 1
					continue
			while itmp in Aset:
				itmp += 1
				anstmp += 1
			ans = max(ans, anstmp)
		print(ans)
main()


t = int(input())
while t:
	t = t - 1
	(n, x) = list(map(int, input().split(' ')))
	lst = list(map(int, input().split(' ')))
	lst1 = [0 for i in range(500)]
	for i in range(len(lst)):
		lst1[lst[i]] = 1
	j = 0
	while x:
		j = j + 1
		if lst1[j] == 1:
			pass
		else:
			lst1[j] = 1
			x = x - 1
	for i in range(1, 500):
		if lst1[i] == 0:
			break
	print(i - 1)


import sys
t = int(sys.stdin.readline().strip())

def arr_to_int_arr(a_arr):
	result = [0] * 210
	for a in a_arr:
		result[a - 1] = 1
	return result

def fill_n_times_and_count(result_arr, x):
	count_0 = 0
	filled = False
	for (i, elem) in enumerate(result_arr):
		if filled:
			if elem == 0:
				return i
		if elem == 0:
			count_0 += 1
			if count_0 == x:
				filled = True
for t_curr in range(t):
	next_line = sys.stdin.readline().strip()
	arr_tmp = [int(val) for val in next_line.split(' ')]
	n = arr_tmp[0]
	x = arr_tmp[1]
	next_line = sys.stdin.readline().strip()
	a_arr = [int(val) for val in next_line.split(' ')]
	result_arr = arr_to_int_arr(a_arr)
	print(fill_n_times_and_count(result_arr, x))


cases = int(input())
for case in range(cases):
	(n, x) = input().split()
	pos = input().split()
	n = int(n)
	x = int(x)
	maxx = n + x
	places = [int(a) for a in pos if int(a) <= maxx]
	for i in range(1, maxx + 1):
		if i not in places:
			x -= 1
		if x < 0:
			break
		rr = i
	print(rr)


from pprint import pprint
import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(n, x) = map(int, input().split())
	dat = list(map(int, input().split()))
	dat = list(set(dat))
	dat.sort()
	l = len(dat)
	cur = 0
	res = -1
	for i in range(l):
		d = dat[i] - cur
		if d < 2:
			cur = dat[i]
			continue
		if x >= d - 1:
			x -= d - 1
		else:
			cur = cur + x
			x = 0
			break
		cur = dat[i]
	if x > 0:
		cur += x
	print(cur)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	A = [int(x) for x in input().split()]
	i = 0
	c = 0
	B = []
	while c <= x:
		i += 1
		if i in A:
			B.append(i)
		else:
			c += 1
			B.append(i)
	print(max(B) - 1)
	t -= 1


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


def dkwpwn(n, x, lists):
	lists = list(set(lists))
	count = 0
	while x > 0:
		count += 1
		if count not in lists:
			x -= 1
	while count + 1 in lists:
		count += 1
	return count
q = int(input())
for _ in range(q):
	(n, x) = list(map(int, input().split()))
	lists = list(map(int, input().split()))
	print(dkwpwn(n, x, lists))


import sys, itertools, math, collections, random

def ia():
	return [int(i) for i in sys.stdin.readline().strip().split(' ')]

def ii():
	return int(sys.stdin.readline().strip())

def istr():
	return sys.stdin.readline().strip()
for _ in range(ii()):
	(n, x) = ia()
	A = sorted(set(ia()))
	ans = 0
	for i in range(1, 300):
		if i in A:
			continue
		if x == 0:
			break
		else:
			x -= 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	got = 0
	flag = False
	for i in range(0, n):
		if arr[i] - got <= x and arr[i] != got and (arr[i] > got):
			flag = True
			x -= arr[i] - got - 1
			got += arr[i] - got
		elif x != 0 and got != arr[i]:
			flag = True
			got += x
			x = 0
			if arr[i] - got == 1:
				got += 1
		else:
			flag = True
			if arr[i] - got == 1:
				got += 1
	if flag:
		got += x
	else:
		got = x
	print(got)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	tmp = 1
	while b > 0:
		if tmp in l:
			tr = 1
		else:
			b = b - 1
			l.append(tmp)
		tmp += 1
	cnt = 1
	l.sort()
	for i in range(1, len(l)):
		if l[i] == l[i - 1] + 1:
			cnt += 1
		elif l[i] == l[i - 1]:
			tr = 1
		else:
			break
	print(cnt)


def solve(a, x):
	a = set(a)
	result = 0
	for i in range(x):
		result += 1
		while result in a:
			result += 1
	while result + 1 in a:
		result += 1
	return result
for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	print(solve(a, x))


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	m = 1
	while x:
		if m not in a:
			x -= 1
			if x == 0:
				m += 1
				break
		m += 1
	while m in a:
		m += 1
	print(m - 1)


t = int(input())
while t > 0:
	t = t - 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = dict()
	for i in a:
		if b.get(i):
			continue
		b[i] = 1
	n = len(b)
	i = 0
	c = 1
	while True:
		if b.get(c):
			c += 1
			continue
		if x == 0:
			break
		x -= 1
		c += 1
	print(c - 1)


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())

def solve():
	mark = [False] * 201
	for i in a:
		mark[i] = True
	ans = 1
	l = 0
	h = 201
	while l < h:
		i = (l + h) // 2
		req = x
		ok = True
		for j in range(1, i + 1):
			if not mark[j]:
				if req > 0:
					req -= 1
				else:
					ok = False
					break
			ans = j
		if ok:
			l = i + 1
		else:
			h = i
	return ans
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(solve())


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')
testcases = int(input())
for j in range(testcases):
	values = list(map(int, input().split()))
	n = values[0]
	x = values[1]
	set1 = set(map(int, input().split()))
	list1 = list(set1)
	newlist1 = [0 for b in range(202)]
	for s in range(len(list1)):
		newlist1[list1[s] - 1] += 1
	highestsofar = 0
	for k in range(len(newlist1)):
		if newlist1[k] == 0:
			if x >= 1:
				x += -1
				highestsofar += 1
			elif x == 0:
				break
		else:
			highestsofar = k + 1
	print(highestsofar)


t = int(input())
for i10 in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	k = 0
	while i < len(a):
		if i != 0 and a[i] == a[i - 1]:
			i += 1
		elif a[i] == k + 1:
			k += 1
			i += 1
		elif a[i] != k + 1:
			x -= 1
			k += 1
		if x == -1:
			k -= 1
			break
	while x > 0:
		k += 1
		x -= 1
	print(k)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	lis = set(map(int, input().split()))
	i = 1
	while x > 0:
		if i in lis:
			i = i + 1
			continue
		else:
			x = x - 1
			if x > 0:
				i = i + 1
	while i + 1 in lis:
		i = i + 1
	print(i)


L = set(range(1, 202))
for usls in range(int(input())):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	l = sorted(list(L.difference(a)))
	print(l[x] - 1)


def solve():
	(n, x) = map(int, input().split())
	s = list(map(int, input().split()))
	s.sort()
	best = s[0]
	x -= s[0] - 1
	if x < 0:
		return x + s[0] - 1
	for i in range(1, n):
		raz = max(s[i] - s[i - 1] - 1, 0)
		if raz <= x:
			best = s[i]
			x -= raz
		else:
			break
	return best + x
t = int(input())
for i in range(t):
	print(solve())


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	mas = [int(i) for i in input().split()]
	s = [0 for i in range(1000)]
	for i in range(n):
		s[mas[i] - 1] = 1
	i = 0
	last = -1
	while x != -1:
		if s[i] == 0:
			x -= 1
		last = i
		i += 1
	print(last)


def solve(a, x):
	for i in range(len(a) - 1):
		m = a[i + 1] - a[i] - 1
		if m <= x:
			x -= m
		else:
			return a[i] + x
	return a[-1] + x
for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted([i for i in set([int(i) for i in input().split()])])
	if n == 1:
		print(x if x - a[0] < -1 else x + 1)
	else:
		b = [0]
		b.extend(a)
		print(solve(b, x))


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	a = sorted(list(a))
	best = x
	for (i, e) in enumerate(a):
		missing = e - i - 1
		if missing > x:
			break
		else:
			best = max(best, e + (x - missing))
	print(best)


test = int(input())
for _ in range(test):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a.sort()
	cnt = [0] * 300
	for i in a:
		cnt[i] += 1
	for i in range(1, 300):
		if cnt[i] == 0 and x > 0:
			cnt[i] = 1
			x -= 1
	for i in range(1, 300):
		if cnt[i] == 0:
			print(i - 1)
			break


import sys
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7
INF = float('inf')

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

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	la = [False] * 202
	(n, x) = inpl()
	a = inpl()
	for i in a:
		la[i - 1] = True
	now = 0
	while x >= 0:
		if not la[now]:
			x -= 1
			if x < 0:
				break
		now += 1
	print(now)


for case in range(int(input())):
	(N, X) = map(int, input().split())
	L = list(set(map(int, input().split())))
	L.sort()
	cur = 0
	for pos in L:
		num = pos - cur - 1
		if num > X:
			cur += X
			X = 0
			break
		X -= num
		cur = pos
	print(cur + X)


for t in range(int(input())):
	(_, x) = [int(e) for e in input().split(' ')]
	a = [int(e) for e in input().split(' ')]
	a.sort()
	prev = 0
	result = 0
	for value in a:
		while prev != value:
			if value == prev + 1:
				result += 1
				prev += 1
			elif x > 0:
				x -= 1
				prev += 1
				result += 1
			else:
				break
	result += x
	print(result)


def solve(a, x):
	s = set(a)
	possition = 0
	while True:
		possition += 1
		if possition not in s:
			if x == 0:
				return possition - 1
			x -= 1

def main():
	n = int(input())
	for i in range(n):
		(_, x) = [int(x) for x in input().split()]
		a = [int(x) for x in input().split()]
		print(solve(a, x))
main()


for i in range(int(input())):
	(n, x) = [int(s) for s in input().split()]
	data = [int(s) for s in input().split()]
	arr = [0] * 494
	for i in data:
		arr[i] = 1
	i = 1
	while x != 0 or arr[i] != 0:
		if arr[i] == 0:
			x -= 1
		i += 1
	print(i - 1)


for case in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	ranks = [int(x) for x in input().split()]
	rank_achived = {}
	for i in range(1, 202):
		rank_achived[i] = False
	for r in ranks:
		rank_achived[r] = True
	final_rank = 0
	for r in range(1, 202):
		if rank_achived[r] == False:
			rank_achived[r] = True
			x -= 1
		if x == 0:
			final_rank = r
			break
	while True:
		if rank_achived[final_rank] == True:
			final_rank += 1
		else:
			break
	print(final_rank - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	s = set(a)
	p = 1
	i = 0
	while True:
		if p not in s:
			i += 1
			if i == x:
				break
		p += 1
	while True:
		if p + 1 in s:
			p += 1
		else:
			break
	print(p)


t = int(input())
while t > 0:
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	a_new = list(set(a))
	l = 0
	for i in range(1, 201):
		r = set(list(range(1, i + 1))) - set(a)
		q = len(r)
		if q == x:
			l = max(l, i)
		else:
			continue
	print(l)
	t = t - 1


times = int(input())
ans_list = []
for i in range(times):
	x = input()
	x = x.split()
	scores = input()
	scores = scores.split()
	scores = [int(i) for i in scores]
	minim = min(scores)
	adding = 0
	already = 0
	count = int(x[0])
	round = int(x[1])
	for i in range(1, 1000):
		if adding < round:
			if i not in scores:
				adding += 1
			else:
				already += 1
		elif i in scores:
			already += 1
		else:
			break
	print(adding + already)


def main():
	t = int(input())
	for i in range(t):
		(n, k) = [int(x) for x in input().split(' ')]
		nums = [int(x) for x in input().split(' ')]
		res = n + k
		while res > 0:
			count = 0
			for j in range(res):
				if nums.count(j + 1) > 0:
					count += 1
			if count + k >= res:
				print(res)
				break
			res -= 1
main()


import math
alph = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * 100
	for i in range(n):
		b[a[i] - 1] += 1
	for i in range(max(a)):
		if b[i] == 0:
			if x != 0:
				x -= 1
			else:
				print(i)
				break
	else:
		print(max(a) + x)


from sys import stdin, stdout
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()

def main():
	T = int(rl())
	for _ in range(T):
		(n, x) = (int(i) for i in rll())
		A = [int(i) for i in rll()]
		A.sort()
		v = 0
		for i in range(-1, n - 1):
			delta = 0
			if i >= 0:
				delta = A[i + 1] - A[i] - 1
			else:
				delta = A[0] - 1
			if delta > 0:
				if x - delta >= 0:
					v = A[i + 1]
					x -= delta
				else:
					v += x
					x = 0
					break
			elif delta == 0:
				v = A[i + 1]
		v += x
		stdout.write(str(v))
		stdout.write('\n')
	stdout.close()
main()


ncases = int(input())
answer = []
for i in range(ncases):
	line1 = input().split(' ')
	line2 = input().split(' ')
	l1 = [0]
	l2 = []
	for char in line2:
		l1.append(int(char))
	if len(l1) == 2:
		gap = l1[1] - l1[0]
		l2.append(gap)
	else:
		l1.sort()
		for j in range(len(l1) - 1):
			gap = l1[j + 1] - l1[j]
			l2.append(gap)
	chance = int(line1[1])
	for k in range(0, len(l2)):
		gap = l2[k]
		if gap <= 1:
			chance = chance
		else:
			chance = chance - gap + 1
			if chance < 0:
				maxpossible = l1[k] + chance + gap - 1
				answer.append(maxpossible)
				chance = -1
				break
			elif chance == 0 and l1[-1] == l1[k + 1]:
				answer.append(l1[k + 1])
				chance = -1
				break
	if chance > 0:
		maxposs = l1[-1] + chance
		answer.append(maxposs)
	if chance == 0:
		answer.append(l1[-1])
for ans in answer:
	print(ans)


tc = int(input())
while tc != 0:
	l1 = [int(i) for i in input().split()]
	l1 = l1[1]
	l2 = [int(i) for i in input().split()]
	l = [0 for i in range(202)]
	for i in l2:
		l[i] = 1
	for i in range(1, 202):
		l[i] = l[i] + l[i - 1]
	for i in reversed(range(202)):
		if i - l1 == l[i]:
			print(i)
			break
	tc -= 1


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = [int(_) for _ in input().split()]
	ans = 0
	for j in range(1, 10000):
		if j in a:
			pass
		elif x > 0:
			x -= 1
		else:
			ans = j - 1
			break
	print(ans)


def solve():
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = []
	for o in range(0, 1000):
		b.append(0)
	for j in range(len(a)):
		b[a[j]] += 1
	v = 1
	while 1:
		if b[v] != 0:
			v += 1
		elif x > 0:
			x -= 1
			v += 1
		else:
			v -= 1
			break
	print(v)
t = input().split()
t = int(t[0])
for _ in range(t):
	solve()


t = int(input())

def solve(n, x, a):
	cnt = 0
	for i in range(1, n + x + 1):
		if i not in a:
			cnt += 1
		if cnt > x:
			return i - 1
	return x + n
for i in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	print(solve(n, x, a))


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

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

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

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		(n, x) = num()
		a = li()
		s = set(a)
		cc = 1
		while x != 0:
			if cc in s:
				cc += 1
				continue
			x -= 1
			s.add(cc)
			cc += 1
		cc = 1
		pp = 0
		while cc in s:
			pp += 1
			cc += 1
		print(pp)
solve()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = [0] + sorted(set(a)) + [1000]
	fans = 0
	i = 1
	for i in range(1, len(a)):
		y = a[i] - a[i - 1] - 1
		if x >= a[i] - a[i - 1] - 1:
			x -= a[i] - a[i - 1] - 1
			fans = a[i]
		else:
			fans += x
			x -= x
			break
	print(fans)


def solve():
	T = int(input())
	for t in range(T):
		(n, x) = map(int, input().split())
		arr = list(map(int, input().split()))
		s = set()
		for n in arr:
			s.add(n)
		p = 0
		for n in range(1, 101):
			if n not in s:
				x -= 1
				s.add(n)
			if x < 0:
				break
			p = n
		for i in range(x):
			p += 1
		print(p)
solve()


import math
for ii in range(int(input())):
	(n, x) = map(int, input().split())
	l = [int(i) for i in input().split()]
	a = sorted(list(set(l)))
	i = 0
	count = 0
	while i <= len(a) and x >= 0:
		if i < len(a) and a[i] == count + 1:
			i += 1
			count += 1
		else:
			x -= 1
			count += 1
	print(count + x)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(s) for s in input().split()]
	b = [0 for i in range(201)]
	for j in a:
		b[j - 1] = 1
	for j in range(201):
		if b[j] == 0:
			if x > 0:
				b[j] += 1
				x -= 1
			else:
				print(j)
				break


garbage = int(input())
while garbage:
	(n, x) = map(int, input().rstrip().split(' '))
	list_1 = list(map(int, input().rstrip().split(' ')))
	last = 1
	i = 0
	while i != x:
		if last not in list_1:
			list_1.append(last)
			i = i + 1
		last = last + 1
	list_1.sort()
	res = list_1[n + x - 1]
	for z in range(1, len(list_1)):
		if list_1[z] - list_1[z - 1] > 1:
			res = list_1[z - 1]
			break
	print(res)
	garbage = garbage - 1


t = int(input())
while t > 0:
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	a = list(map(int, input().strip().split(' ')))
	i = 1
	while x > 0:
		if i not in a:
			x -= 1
		i += 1
	while i in a:
		i += 1
	print(i - 1)
	t -= 1


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	j = 1
	r = 0
	count = 0
	while j <= n + x:
		if j not in a:
			r += 1
			if r == x:
				for k in range(j + 1, n + x + 1):
					if k in a:
						count += 1
					else:
						break
				print(j + count)
				break
		j += 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l = list(set(l))
	prev = 0
	pos = 0
	l.sort()
	for i in l:
		if x >= i or i - x == 1:
			x += 1
	print(x)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	tmp = x
	for i in range(1, n + x + 2):
		if i in a:
			continue
		elif tmp > 0:
			tmp -= 1
		else:
			print(i - 1)
			break


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = sorted(set(list(map(int, input().split()))))
	i = 1
	while m > 0 or i in a:
		if i not in a:
			m -= 1
			i += 1
		else:
			i += 1
	print(i - 1)


def fun(x):
	return list(dict.fromkeys(x))
for i in range(int(input())):
	lis = []
	m = 0
	(n, x) = map(int, input().split())
	lis = list(map(int, input().split()))
	for i in range(1, x + 1):
		while i in lis:
			i += 1
		if i not in lis:
			lis.append(i)
	lis = fun(lis)
	lis.sort()
	for j in range(len(lis) - 1):
		if lis[j] + 1 == lis[j + 1]:
			m += 1
		else:
			break
	print(m + 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	i = 1
	while x != -1:
		if i not in a:
			x -= 1
		i += 1
	print(i - 2)


import sys

def f(n, x, a):
	x1 = x
	i = 0
	b = set(a)
	while 1:
		i += 1
		if i in b:
			continue
		elif x1 == 0:
			return i - 1
		else:
			x1 -= 1
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
N = inp()
for i in range(N):
	L1 = inlt()
	L2 = inlt()
	print(f(L1[0], L1[1], L2))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	(n, k) = get_int_list()
	lst = get_int_list()
	lst = list(set(lst))
	lst.sort()
	n = len(lst)
	for i in range(n):
		if lst[i] <= k:
			k += 1
	while k + 1 in lst:
		k += 1
	print(k)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 1
	c = [False for i in range(205)]
	for i in range(n):
		c[a[i]] = True
	for i in range(1, 205):
		w = c[:i + 1].count(True)
		if w + x >= i:
			ans = i
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	c = {*map(int, input().split())}
	cnt = 1
	for i in range(n + x + 1):
		if cnt in c:
			pass
		elif x == 0:
			break
		else:
			x -= 1
			c.add(cnt)
		cnt += 1
	print(cnt - 1)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

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

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

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

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, x) = li()
	l = sorted(set(li()))
	p = set(l)
	i = j = 0
	n = len(l)
	while i < n and x:
		if l[i] != j + 1:
			x -= 1
			p.add(j + 1)
		else:
			i += 1
		j += 1
	while x:
		p.add(j + 1)
		j += 1
		x -= 1
	p = sorted(list(p))
	ans = len(p)
	for j in range(len(p)):
		if p[j] != j + 1:
			ans = j
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	was = [False] * 300
	for i in range(n):
		was[a[i]] = True
	for i in range(1, 300):
		if x <= 0:
			break
		if not was[i]:
			was[i] = True
			x -= 1
	v = 0
	for i in range(1, 300):
		if not was[i]:
			v = i
			break
	print(v - 1)


T = int(input())
for t in range(T):
	(n, x) = [int(i) for i in input().split()]
	A = set([int(i) for i in input().split()])
	n = len(A)
	for i in range(1, 1000):
		if i not in A:
			if x > 0:
				x -= 1
			else:
				print(i - 1)
				break


for num in range(int(input())):
	[n, x] = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = list(set(a))
	p.sort()
	b = [0] + p + [1000000000000000000000000000000000000000000000]
	i = 0
	sum = 0
	while sum <= x:
		sum += b[i + 1] - b[i] - 1
		i += 1
	sum -= b[i] - b[i - 1] - 1
	print(b[i - 1] + x - sum)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ai = list(map(int, input().split()))
	ai.sort()
	ans = 0
	for j in range(n):
		if ans == ai[j]:
			continue
		if x < ai[j] - ans - 1:
			break
		x -= ai[j] - ans - 1
		ans = ai[j]
	print(ans + x)


def main():
	t = int(input())
	for _ in range(t):
		(n, x) = [int(i) for i in input().split()]
		arr = {int(i) for i in input().split()}
		arr = list(arr)
		arr.sort()
		current = 0
		for el in arr:
			need = el - current - 1
			if x >= need:
				x -= need
			else:
				break
			current = el
		answer = current + x
		print(answer)
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	place = 0
	while True:
		place += 1
		if place not in a:
			if x == 0:
				place -= 1
				break
			x -= 1
	print(place)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	mass = [int(x) for x in input().split()]
	arr = [0] * 1002
	for j in range(n):
		arr[mass[j] - 1] = 1
	u = 0
	for j in range(1002):
		if not arr[j]:
			if x > 0:
				x -= 1
				continue
			u = j
			break
	print(u)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	for m in range(1, 2000):
		if m in a:
			continue
		elif x > 0:
			x -= 1
		else:
			print(m - 1)
			break


for T in range(int(input())):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	d = {}
	Max = arr[0]
	for i in range(n):
		d[arr[i]] = 1
		Max = max(Max, arr[i])
	Max_ind = 0
	for i in range(1, Max + 1):
		if not i in d:
			if x == 0:
				break
			else:
				d[i] = 1
				x -= 1
				Max_index = i
		else:
			Max_index = i
	if x == 0:
		print(Max_index)
	else:
		print(Max_index + x)


from functools import reduce
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(delimiter=' '):
		return input().split(delimiter)

	@staticmethod
	def list_int(delimiter=' '):
		return list(map(int, input().split(delimiter)))

def main():
	t = Read.int()
	for _ in range(t):
		(n, x) = Read.list_int()
		a = sorted(set(Read.list_int()))
		i = 1
		while x:
			if i in a:
				i += 1
			else:
				x -= 1
				i += 1
		while i in a:
			i += 1
		print(i - 1)
main()


import sys

class ADreamoonAndRankingCollection:

	def solve(self):
		for _ in range(int(input())):
			(n, x) = [int(_) for _ in input().split()]
			a = [int(_) for _ in input().split()]
			done = [0] * max(a)
			for i in range(n):
				done[a[i] - 1] = 1
			rem = x
			for i in range(max(a)):
				if done[i] == 0:
					done[i] = 1
					rem -= 1
				if rem == 0:
					break
			if 0 not in done:
				ans = len(done) + rem
			else:
				ans = done.index(0)
			print(ans)
solver = ADreamoonAndRankingCollection()
input = sys.stdin.readline
solver.solve()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set()
	for i in range(1, 300):
		if i in a:
			s.add(i)
			continue
		if x == 0:
			break
		if i not in s:
			s.add(i)
			x -= 1
	print(max(s))


tc = int(input())
for t in range(0, tc):
	inp = input().split()
	n = int(inp[0])
	x = int(inp[1])
	arr = input().split()
	int_arr = []
	for i in arr:
		int_arr.append(int(i))
	int_arr.sort()
	temp_arr = []
	num_added = 1
	tempx = x
	for temp in range(1, max(int_arr) + 1):
		if temp not in int_arr:
			if num_added <= x:
				temp_arr.append(temp)
				num_added += 1
				tempx -= 1
			else:
				break
	for items in temp_arr:
		int_arr.append(items)
	int_arr.sort()
	newls = list(set(int_arr))
	if tempx != 0:
		for i in newls:
			if i + 1 not in newls:
				newls.append(i + 1)
				tempx -= 1
				if tempx == 0:
					break
	newls.sort()
	flag = 0
	for i in range(0, len(newls) - 1):
		if newls[i + 1] != newls[i] + 1:
			print(newls[i])
			flag = 1
			break
	if flag == 0:
		print(newls[len(newls) - 1])


for t in range(int(input())):
	(n, x) = map(int, input().split())
	nums = list(map(int, input().split()))
	num = 0
	while x >= 0:
		num += 1
		if not num in nums:
			x -= 1
	print(num - 1)


for _ in range(int(input())):
	(n, x) = tuple(map(int, input().split()))
	arr = set(map(int, input().split()))
	i = 1
	cnt = 0
	ans = 0
	while cnt <= x:
		while i in arr:
			i += 1
		arr.add(i)
		cnt += 1
		if cnt != x - 1:
			ans = i
	print(ans - 1)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	arr = set(map(int, input().split()))
	for i in range(1, 10000):
		if i not in arr:
			if x > 0:
				x -= 1
			elif x == 0:
				print(i - 1)
				break


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.append(0)
	a = sorted(list(set(a)))
	c = []
	for i in range(len(a) - 1):
		c.append(a[i + 1] - a[i] - 1)
	d = -1
	for i in range(len(c)):
		x = x - c[i]
		if x < 0:
			x = x + c[i]
			d = i
			break
	print(a[d] + x)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	p = [0] * 207
	for ai in a:
		p[ai] = 1
	pos = 1
	while p[pos] == 1 or x > 0:
		if p[pos] == 0:
			x -= 1
		pos += 1
	print(pos - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	coll = [0] * 200
	for i in a:
		coll[i - 1] = 1
	index = 0
	for i in range(x):
		while index < 200 and coll[index]:
			index += 1
		if index >= 200:
			break
		coll[index] = 1
	while index < 200 and coll[index]:
		index += 1
	print(index)


t = int(input())
for tc in range(t):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	ans = 0
	for i in range(1, max(a) + 1):
		if x == 0 and i not in a:
			break
		if i not in a:
			ans = i
			x -= 1
		else:
			ans = i
	ans += x
	print(ans)


t = int(input())
import math
delay = []
for _ in range(t):
	(n, x) = map(int, input().split())
	a = input().split()
	a = [int(i) for i in a]
	a = list(set(a))
	a.sort()
	tent = x
	for ele in a:
		if ele <= tent:
			tent += 1
		elif ele == tent + 1:
			tent += 1
		else:
			break
	delay.append(tent)
for d in delay:
	print(d)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(set(a))
	b.sort()
	c = []
	for i in range(1, 202):
		if i not in b:
			c.append(i)
	print(c[x - 1] if c[x] - c[x - 1] == 1 else c[x] - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	nums = sorted(set(map(int, input().split())))
	reach = i = 0
	while i < len(nums):
		if nums[i] == reach + 1:
			reach += 1
			i += 1
		else:
			if x == 0:
				break
			reach += 1
			x -= 1
	while x:
		reach += 1
		x -= 1
	print(reach)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	s = set(list(map(int, input().split())))
	f = set([1])
	i = 1
	while len(f - s) <= x:
		i += 1
		f.add(i)
	else:
		print(len(f) - 1)


t = int(input())
for z in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(set(list(map(int, input().split()))))
	a.sort()
	v = 0
	left = x
	for i in range(len(a)):
		if a[i] - i - 1 <= x:
			v = a[i]
			left = x - (a[i] - i - 1)
		else:
			break
	if left > 0:
		v = v + left
	print(v)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	diff = [arr[0] - 1 - 1]
	for i in range(1, n):
		diff.append(arr[i] - arr[i - 1] - 1)
	i = 0
	if arr[0] != 1:
		x -= 1
	ans = 1
	while i < n and x >= diff[i]:
		ans = arr[i]
		if diff[i] > 0:
			x -= diff[i]
		i += 1
	ans += x
	print(ans)


t = int(input())
for y in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [0 for i in range(500)]
	j = 1
	for i in a:
		l[i] = 1
	for i in range(k):
		while l[j] == 1:
			j += 1
		l[j] = 1
	while l[j] == 1:
		j += 1
	print(j - 1)


for test_i in range(int(input())):
	(n, x) = map(int, input().split())
	places = [False for i in range(201)]
	for place in list(map(int, input().split())):
		places[place - 1] = True
	curi = 0
	while places[curi]:
		curi += 1
	for i in range(x):
		curi += 1
		while places[curi]:
			curi += 1
	print(curi)


t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().strip().split(' '))
	arr = list(map(int, input().strip().split(' ')))
	a = [0] * 210
	for i in range(0, n):
		a[arr[i]] = 1
	cnt = 0
	ans = -1
	for i in range(1, 210):
		if a[i] == 0:
			a[i] = 1
			cnt += 1
		if cnt == x:
			ans = i
			break
	cnt = 0
	for i in range(1, 210):
		if a[i] == 1:
			cnt += 1
		else:
			break
	print(cnt)


def soln(a, x):
	table = [False for _ in range(200)]
	for elem in a:
		table[elem - 1] = True
	ctr = 0
	for (i, elem) in enumerate(table):
		if not elem:
			table[i] = True
			ctr += 1
		if ctr == x:
			break
	result = 0
	for elem in table:
		if elem:
			result += 1
		else:
			break
	return result

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = [int(i) for i in input().split(' ')]
		a = [int(i) for i in input().split(' ')]
		result = soln(a, x)
		print(result)

def test():
	a = [3, 1, 1, 5, 7, 10]
	x = 2
	print(soln(a, x))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	pos = [0] * 201
	for i in range(n):
		pos[a[i]] = 1
	c = 1
	while k >= 0 and c <= 200:
		if pos[c] == 0:
			k -= 1
			if k < 0:
				break
		c += 1
	print(c - 1)


t = int(input())
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	liste = list(map(int, input().split()))
	k = 1
	while k < x + 2:
		if k in liste:
			k += 1
			x += 1
		else:
			liste.append(k)
			k += 1
	print(liste[-1] - 1)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(n, x) = list(map(int, input().split()))
		arry = list(map(int, input().split()))
		ans = [0] * (n + x)
		for ele in arry:
			if ele <= n + x:
				ans[ele - 1] = 1
		res = None
		xcop = x
		for i in range(n + x):
			if ans[i] == 0:
				if xcop > 0:
					xcop -= 1
				else:
					res = i
					break
		if not res:
			res = n + x
		yield res
t = int(input())
ans = gift()
print(*ans, sep='\n')


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(set(a))
	a = sorted(a)
	s = x
	h = 1
	d = a[0] - 1
	if d <= s:
		h = a[0]
		s -= d
	else:
		h = s
		s = 0
	for i in range(len(a) - 1):
		d = a[i + 1] - a[i] - 1
		if d <= s:
			s -= d
			h = a[i + 1]
		else:
			h += s
			s = 0
			break
	if s > 0:
		h += s
	print(h)


def matches(n, x, a):
	c = 0
	output = []
	while True:
		if c + 1 in a:
			c += 1
		elif x > 0:
			c += 1
			x -= 1
		else:
			break
	output.append(c)
	for o in output:
		print(o)
t = int(input())
for i in range(t):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	ans = matches(n, x, a)
	ans


for t in range(int(input())):
	(n, x) = map(int, input().split())
	List = list(map(int, input().split()))
	List = list(set(List))
	List.sort()
	copy = x
	count = 0
	for i in List:
		count += 1
		copy += 1
		if i > copy:
			copy -= 1
			break
	print(copy)


import math
for w in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b = list(set(b))
	b.sort()
	dif = b[0] - 1
	aux = a[1] - dif
	flag = 0
	if aux < 0:
		print(a[1])
	else:
		for i in range(len(b) - 1):
			if b[i + 1] - b[i] - 1 <= aux:
				aux -= b[i + 1] - b[i] - 1
				flag = i + 1
			else:
				break
		print(b[flag] + aux)


t = int(input())

def find(n, x, arr):
	narr = []
	for k in arr:
		if not k in narr:
			narr.append(k)
	for l in range(x):
		for i in range(1, 1000):
			if i in narr:
				continue
			else:
				narr.append(i)
				break
	narr.sort()
	for l in range(len(narr)):
		if l == len(narr) - 1:
			print(narr[l])
			break
		if narr[l + 1] - narr[l] == 1:
			continue
		else:
			print(narr[l])
			break
for k in range(t):
	(n, x) = map(int, input().split())
	arr = map(int, input().split())
	find(n, x, arr)


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	lis = list(map(int, input().split()))
	d = defaultdict(int)
	for i in lis:
		d[i] = 1
	for i in range(1, 500):
		if d[i] == 1:
			continue
		if x == 0:
			break
		x -= 1
		d[i] = 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	now = 1
	while x >= 0:
		if now not in a:
			if x == 0:
				break
			x -= 1
		ans += 1
		now += 1
	print(ans)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def solve():
	(n, x) = Scanner.map_int()
	A = Scanner.map_int()
	A = sorted(list(set(A)))
	ans = 1
	while x > 0:
		if not ans in A:
			x -= 1
		ans += 1
	while ans in A:
		ans += 1
	ans -= 1
	print(ans)

def main():
	T = Scanner.int()
	for _ in range(T):
		solve()
main()


I = input
pr = print

def main():
	for _ in range(int(I())):
		(n, x) = map(int, I().split())
		ar = set(map(int, I().split()))
		pr(list(set(range(1, 205)) - ar)[x] - 1)
main()


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	Query.append((N, K, A))
for (N, K, A) in Query:
	B = set(A)
	c = 0
	for v in range(1, N + K + 3):
		if not v in B:
			if c == K:
				break
			c += 1
	print(v - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = set(map(int, input().split()))
	itr = 0
	while x >= 0:
		itr += 1
		if itr not in arr:
			if x == 0:
				itr -= 1
				break
			x -= 1
	print(itr)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	a = set(l)
	l = list(a)
	l.sort()
	l = l[::-1]
	for i in range(len(l)):
		if l[i] == x + len(l[i + 1:]) + 1:
			print(l[i])
			break
		elif l[i] + 1 <= x + len(l[i + 1:]) + 1:
			print(x + len(l[i + 1:]) + 1)
			break
		elif i == len(l) - 1:
			print(x)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	chk = [0] * 210
	a = [int(x) for x in input().split()]
	for x in a:
		chk[x] = 1
	for x in range(1, 210):
		if chk[x] == 0:
			m -= 1
			if m < 0:
				print(x - 1)
				break


t = int(input())
INF = 302
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	pref = [0 for _ in range(INF)]
	v = 0
	for i in range(n):
		pref[a[i] - 1] = 1
	for j in range(INF):
		if sum(pref[0:j + 1]) + x >= j + 1:
			v = max(j + 1, v)
	print(v)


t = int(input())
res = []
for i in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	l = []
	c = 0
	for i in range(1, x + 1):
		l.append(i)
	max = l[-1]
	for i in l:
		if a.count(i) > 0:
			c = c + 1
	for i in range(1, c + 1):
		temp = max + 1
		flag = 1
		while True:
			if a.count(temp) > 0:
				temp = temp + 1
				flag = 0
				continue
			else:
				l.append(temp)
				flag = 1
				break
		max = l[-1]
	v = l[-1]
	flag = 1
	while True:
		temp = v + 1
		if a.count(temp) > 0:
			v = temp
			flag = 1
			continue
		else:
			flag = 0
			break
	res.append(v)
for i in res:
	print(i)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(N, X) = map(int, input().split())
	A = set(map(int, input().split()))
	ans = 1
	while X:
		if ans not in A:
			X -= 1
		if not X:
			break
		ans += 1
	while ans + 1 in A:
		ans += 1
	print(ans)


t = int(input())
for h in range(0, t):
	k = 0
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	for i in range(1, 10000):
		if i not in a:
			x = x - 1
		if x < 0:
			print(i - 1)
			k = 1
			break


amount = int(input())
for i in range(amount):
	(n, x) = [int(s) for s in input().split()]
	array = [int(s) for s in input().split()]
	max_ = max(array)
	min_ = min(array)
	not_enough = 0
	for i in range(1, max_):
		if i not in array:
			not_enough += 1
	if x >= not_enough:
		for i in range(1, 101 + max(0, x - not_enough) + 5):
			if i not in array and x == 0:
				print(i - 1)
				break
			if i not in array:
				x -= 1
	else:
		for i in range(1, max_):
			if i not in array and x == 0:
				print(i - 1)
				break
			if i not in array:
				x -= 1


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	for i in range(1, 100000000):
		if i in arr:
			continue
		elif i not in arr:
			if x == 0:
				print(i - 1)
				break
			else:
				x -= 1


import sys
t = int(sys.stdin.readline())
ans_arr = []
for i in range(t):
	[n, x] = [int(k) for k in sys.stdin.readline().split()]
	a = [int(b) for b in sys.stdin.readline().split()]
	arr = [0] * 210
	for w in range(n):
		arr[a[w]] = 1
	count = 0
	for g in range(1, len(arr)):
		if arr[g] == 0:
			count += 1
		if count <= x:
			ans = g
		else:
			break
	ans_arr.append(str(ans))
print('\n'.join(ans_arr))


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a = set(a)
	counter = 1
	while x > 0:
		if counter not in a:
			a.add(counter)
			x -= 1
		counter += 1
	_max = 0
	counter = 1
	while True:
		if counter not in a:
			_max = counter - 1
			break
		counter += 1
	print(_max)


def answer(n, x, ary):
	ctr = x
	for i in range(1, n + x + 2):
		if i not in ary and ctr == 0:
			return i - 1
		elif i not in ary:
			ctr -= 1
	return

def main():
	t = int(input())
	n = [0] * t
	x = [0] * t
	ary = [0] * t
	for j in range(t):
		(n[j], x[j]) = [int(i) for i in input().split()]
		ary[j] = [int(i) for i in input().split()]
	for j in range(t):
		print(answer(n[j], x[j], ary[j]))
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = sorted([int(x) for x in input().split()])
	s = set(l)
	a = 0
	while x + 1 != 0:
		if a + 1 in s:
			a += 1
		else:
			a += 1
			x -= 1
	print(a - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(map(lambda x: x - 1, a))
	flag = [False] * 300
	for ai in a:
		flag[ai] = True
	for i in range(300):
		if x == 0:
			break
		if not flag[i]:
			flag[i] = True
			x -= 1
	ans = 0
	for i in range(300):
		if flag[i]:
			ans += 1
		else:
			break
	print(ans)


import sys
import math
input = sys.stdin.readline
T = int(input())
for t in range(T):
	(N, X) = map(int, input().split(' '))
	A = list(map(int, input().split(' ')))
	used = set()
	for a in A:
		used.add(a)
	best = N + X
	for i in range(1, best + 1):
		if i in used:
			continue
		X -= 1
		if X == 0:
			break
	while i + 1 in used:
		i += 1
	print(i)


cases = int(input())
for i in range(cases):
	(n, x) = map(int, input().split())
	temp = x
	arr = list(set(map(int, input().split())))
	k = 1
	while temp > 0:
		if k not in arr:
			arr.append(k)
			temp -= 1
		k += 1
	for j in range(k - 1, n + x + 2):
		if j not in arr:
			break
	print(j - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split(' '))
	taken = [False for _ in range(max(100, n + x))]
	for place in map(int, input().split(' ')):
		taken[place - 1] = True
	for (i, v) in enumerate(taken):
		if v:
			continue
		elif x == 0:
			print(i)
			break
		else:
			x -= 1
	else:
		print(len(taken))


t = int(input())
ans = []
for i in range(t):
	(n, x) = map(int, input().split())
	ls = list(map(int, input().split()))
	if 1 in ls:
		ls.append(1)
	else:
		ls.append(0)
	ls.sort()
	cnt = 0
	for j in range(len(ls) - 1):
		flag = 0
		diff = ls[j + 1] - ls[j]
		if (diff == 1 or diff == 0) and x >= 0:
			cnt = ls[j + 1]
		elif diff > 1:
			if x >= diff - 1:
				cnt = ls[j + 1]
				x -= diff - 1
			else:
				if x > 0:
					cnt += x
				x = -1
			if x < 0:
				flag = 1
				ans.append(cnt)
				break
	if flag == 0:
		ans.append(cnt + x)
for k in range(t):
	print(ans[k])


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	sp = list(map(int, input().split()))
	j = 0
	while x > 0:
		j += 1
		if j not in sp:
			x -= 1
		if x == 0:
			k = j + 1
			while k in sp:
				j += 1
				k += 1
	print(j)


p = int(input())
for i in range(p):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a.append(0)
	x += 1
	for i in range(n):
		if a[i] <= x and a[i] != a[i + 1]:
			x += 1
	print(x - 1)


t = int(input())
for _ in range(t):
	[n, x] = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [0] * 201
	for i in a:
		b[i] = 1
	i = 1
	y = 0
	while i < 201:
		if b[i] == 0:
			y = y + 1
		if y > x:
			break
		i = i + 1
	print(i - 1)


test_cases = int(input())
for i in range(test_cases):
	(d, m) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	all_num = list(range(1, d + m + 1))
	missing = [i for i in all_num if i not in arr]
	new = arr + missing[:m]
	all_values = list(set(new))
	all_values.sort()
	v = 0
	for i in range(1, len(all_values)):
		if all_values[i] - all_values[i - 1] != 1:
			v = all_values[i - 1]
			break
	if v != 0:
		print(v)
	else:
		print(len(all_values))


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	v = []
	for i in range(201):
		v.append(0)
	for i in range(n):
		v[l[i]] += 1
	f = 0
	for i in range(1, 201):
		if v[i] == 0:
			x -= 1
			if x < 0:
				f = 1
				break
	if f == 0:
		print(i)
	else:
		print(i - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(sorted(set(a)))
	i = 0
	while x > 0:
		if a[0] != 1:
			a.insert(0, 1)
			x -= 1
		elif i + 1 != len(a):
			if a[i + 1] - a[i] != 1:
				a.insert(i + 1, a[i] + 1)
				i += 1
				x -= 1
			else:
				i += 1
		else:
			a.append(a[i] + 1)
			i += 1
			x -= 1
	while True:
		if i + 1 != len(a) and a[i + 1] == a[i] + 1:
			i += 1
		else:
			break
	print(i + 1)


num = int(input())
for i in range(num):
	(n, x) = map(int, input().split())
	a = [0] + sorted(list(map(int, input().split()))) + [10 ** 3]
	for j in range(len(a) - 1):
		if a[j + 1] - a[j] - 1 <= x:
			x -= max(a[j + 1] - a[j] - 1, 0)
		else:
			print(a[j] + x)
			break


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	used = [False] * 500
	for j in range(n):
		used[a[j] - 1] = True
	j = 0
	while x > 0:
		if used[j] == False:
			used[j] = True
			x -= 1
		j += 1
	ans = 0
	j = 0
	while used[j] == True:
		ans += 1
		j += 1
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l = sorted(list(set(l)))
	v = x
	rank = 1
	i = 0
	while i < x:
		if rank in l:
			v += 1
		else:
			i += 1
		rank += 1
	while True:
		if v + 1 in l:
			v += 1
		else:
			break
	print(v)


from sys import stdin
t = int(input())
for _ in range(t):
	(n, x) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	a = list(set(a))
	M = max(a)
	L = list(range(1, M + x + 2))
	for i in a:
		L.remove(i)
	k = L[x]
	print(k - 1)


t = int(input())
for cas in range(t):
	(n, m) = map(int, input().split())
	a = [int(e) for e in input().split()]
	j = 1
	while True:
		ok = False
		for i in a:
			if i == j:
				ok = True
				j += 1
		if not ok and m:
			ok = True
			j += 1
			m -= 1
		if not ok:
			break
	print(j - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	k = 1
	while x > 0 or l.count(k) > 0:
		if l.count(k) == 0:
			x -= 1
			k += 1
		else:
			k += 1
	print(k - 1)


t = int(input())
for im in range(t):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a = [int(x) for x in set(a)]
	l = len(a)
	a.sort()
	ind = 0
	arr = [0 for x in range(100)]
	for ele in a:
		arr[ele - 1] = 1
	ind = 99
	for i in range(len(arr)):
		if not arr[i]:
			if x:
				x -= 1
			else:
				i -= 1
				ind = i
				break
	ans = ind + x + 1
	print(ans)


t = int(input())
for i in range(0, t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [False] * 202
	for j in range(0, n):
		b[a[j]] = True
	ans = 1
	while x > 0 or b[ans]:
		if not b[ans]:
			x -= 1
		ans += 1
	print(ans - 1)


from collections import defaultdict

def solve(n, x, a):
	m = {}
	for i in range(1, n + x + 1):
		if i not in m:
			m[i] = False
	for i in range(1, n + 1):
		m[a[i]] = True
	for k in range(n + x, -1, -1):
		v = 0
		for i in range(1, k + 1):
			if m[i] == False:
				v += 1
		if v <= x:
			return k
t = int(input())
while t:
	(n, x) = map(int, input().split())
	a = [0] + list(map(int, input().split()))
	print(solve(n, x, a))
	t -= 1


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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))
from types import GeneratorType

def iterative(f, stack=[]):

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

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 zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	(n, x) = sep()
	a = lis()
	cnt = [0] * 6969
	for i in range(n):
		cnt[a[i]] += 6969
	for i in range(1, 300):
		if cnt[i] == 0:
			if x == 0:
				break
			x -= 1
	print(i - 1)
testcase(int(inp()))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(1, 9999999):
		if i in a:
			continue
		elif x > 0:
			x -= 1
		else:
			break
	print(i - 1)


def linput():
	return [int(i) for i in input().split()]
q = int(input())
for ______ in range(q):
	(n, x) = linput()
	a = sorted(linput())
	u = n
	i = 1
	while i < n + 1 and a[i - 1] <= len(set(a[:i])) + x:
		i += 1
	print(len(set(a[:i - 1])) + x)


def main():
	for __ in [0] * int(input()):
		(n, x) = map(int, input().split())
		(*A,) = map(int, input().split())
		S = sorted(set(A))
		maxi = 0
		cnt = 0
		for i in range(1, n + x + 1):
			if i not in S:
				if cnt >= x:
					break
				else:
					cnt += 1
			maxi = i
		print(maxi)
main()


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	achieve = [False] * 201
	for num in a:
		achieve[num] = True
	for k in range(n + x, 0, -1):
		v = 0
		for i in range(1, k + 1):
			if not achieve[i]:
				v += 1
		if v <= x:
			print(k)
			return
for _ in range(int(input())):
	solve()


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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 value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
for _ in range(int(input())):
	ans = [0] * 300
	(n, x) = value()
	a = array()
	for i in a:
		ans[i] = 1
	c = 0
	i = 1
	while c != x:
		if ans[i] == 0:
			c += 1
			ans[i] = 1
		i += 1
	print(ans[1:].index(0))


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	(ct, gt, st) = (0, 0, 0)
	while ct != x:
		st += 1
		if st not in a:
			ct += 1
			a.add(st)
	while True:
		gt += 1
		if gt not in a:
			break
	print(gt - 1)


for T in range(int(input())):
	(n, x) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	arr.sort()
	final = []
	ans = 1
	for i in range(n):
		if arr[i] not in final:
			final.append(arr[i])
	i = 1
	flag = True
	if len(final) == 1:
		if final[0] > x + 1:
			print(x)
			continue
		else:
			print(x + 1)
			continue
	while i < len(final):
		if final[0] != 1 and flag:
			if x < final[0] - 1:
				ans = x
				flag = False
				break
			else:
				x -= final[0] - 1
				ans += final[0] - 1
				flag = False
		if final[i] - final[i - 1] - 1 == 0:
			i += 1
			ans += 1
		elif x >= final[i] - final[i - 1] - 1:
			x -= final[i] - final[i - 1] - 1
			ans += final[i] - final[i - 1]
			i += 1
		else:
			ans += x
			break
	if i == len(final) and x != 0:
		print(ans + x)
	else:
		print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	r = 1
	while x or r in a:
		x -= r not in a
		r += 1
	print(r - 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	v = 0
	a = list(map(int, input().split()))
	while k >= 0:
		if v + 1 in a:
			v += 1
		elif k > 0:
			k -= 1
			v += 1
		else:
			k -= 1
	print(v)


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

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		a = {int(i) for i in input().split()}
		s = 1
		while x:
			if s not in a:
				x -= 1
			s += 1
		while s in a:
			s += 1
		s -= 1
		print(s)
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()


t = int(input())
for _ in range(t):
	(_, x) = map(int, input().split())
	a = set(map(int, input().split()))
	next = 1
	while True:
		if next not in a:
			if x > 0:
				x -= 1
			else:
				break
		next += 1
	print(next - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	hist = [0 for i in range(1000)]
	hist = [None] + hist
	for i in arr:
		hist[i] += 1
	i = 1
	j = x
	while j > 0 and i <= 1000:
		if hist[i] == 0:
			hist[i] += 1
			j += -1
		i += 1
	m = 0
	for i in hist[1:]:
		if i != 0:
			m += 1
		else:
			break
	print(m)


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	for i in a:
		d[i] = 1
	ans = 0
	i = 1
	while x > 0:
		if d[i] == 0:
			x -= 1
			d[i] = 1
		ans = i
		i += 1
	while True:
		if d[i] == 0:
			ans = i - 1
			break
		i += 1
	print(ans)


for _ in range(int(input())):
	(n, a) = map(int, input().split())
	lis = list(map(int, input().split()))
	has = [0] * 250
	c = 0
	for i in lis:
		has[i] = 1
	for i in range(1, 250):
		if has[i] == 0 and a > 0:
			has[i] = 1
			a -= 1
	i = 1
	while has[i] == 1:
		i += 1
	print(i - 1)


from collections import *
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	L = list(map(int, input().split()))
	arr = defaultdict(lambda : 0)
	for i in L:
		arr[i] = 1
	res = 0
	for i in range(1, 300):
		if arr[i] == 1:
			res += 1
		if i - res == b:
			ans = i
		elif i - res > b:
			ans = i - 1
			break
	print(ans)


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

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

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()

def create_z(s):
	z = [0] * len(s)
	x = y = 0
	for i in range(1, len(s)):
		z[i] = max(0, min(z[i - x], y - i + 1))
		while i + z[i] < len(s) and s[z[i]] == s[i + z[i]]:
			x = i
			y = i + z[i]
			z[i] += 1
	return z
for _ in range(ii()):
	(n, k) = mi()
	s = [1] * (n + k + 1000)
	a = li()
	for i in a:
		s[i] = 0
	for i in range(1, len(s)):
		k -= s[i]
		if k < 0:
			print(i - 1)
			break


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	flag = 1
	for i in range(1, 201):
		if i not in a and x != 0:
			x = x - 1
		elif i not in a and x == 0:
			flag = 0
			break
	if flag == 0:
		print(i - 1)
	else:
		print(i)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	print(sorted(set(range(1, 202)).difference(set(map(int, input().split()))))[x] - 1)


from collections import Counter

def main():
	test = int(input())
	for t in range(test):
		l = [int(i) for i in input().split(' ')]
		n = l[0]
		x = l[1]
		l = [int(i) for i in input().split(' ')]
		l = list(set(l))
		l.sort()
		num = 1
		i = 0
		ans = 0
		while i < len(l):
			if l[i] != num:
				if x > 0:
					if l[i] - num <= x:
						ans = l[i]
						x -= l[i] - num
						num = l[i] + 1
					else:
						ans = num + x - 1
						x = 0
						break
				else:
					break
			else:
				num += 1
				ans += 1
			i += 1
		print(ans + x)
main()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	s = [0 for j in range(210)]
	k = list(map(int, input().split()))
	for j in k:
		s[j - 1] += 1
	breakflag = 0
	ans = 0
	for j in range(210):
		if s[j] == 0:
			if x == 0:
				ans = j
				breakflag = 1
			x = x - 1
		if breakflag == 1:
			break
	print(ans)


def solution():
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	cnt = 0
	i = 1
	z = 1
	while z == 1:
		if i not in l:
			x -= 1
		i += 1
		if i not in l and x == 0:
			z = 0
	print(i - 1)
for _ in range(int(input())):
	solution()


for _ in range(int(input())):
	(n, x) = [int(s) for s in input().split()]
	l = list(set([int(s) for s in input().split()]))
	n = len(l)
	l.sort()
	curr = 1
	i = 0
	while x > 0 and i < n:
		if l[i] == curr:
			curr += 1
			i += 1
		else:
			x -= 1
			curr += 1
	while x:
		x -= 1
		curr += 1
	while i < n:
		if l[i] == curr:
			curr += 1
			i += 1
		else:
			break
	print(curr - 1)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	(n, x) = li()
	a = li()
	c = 1
	d = Counter(a)
	while x:
		if c in d:
			c += 1
		else:
			d[c] += 1
			c += 1
			x -= 1
	while True:
		if c in d:
			c += 1
		else:
			break
	print(c - 1)
for _ in range(int(input())):
	case()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	for i in range(1, n + x + 2):
		if i in a:
			pass
		elif x > 0:
			x -= 1
		else:
			print(i - 1)
			break


def solve(arr, x):
	places = [False for i in range(100)]
	for i in arr:
		places[i - 1] = True
	i = 0
	while x > 0 and i < len(places):
		if places[i] == False:
			places[i] = True
			x -= 1
		i += 1
	for i in range(0, 100):
		if places[i] == False:
			return i
	return 100 + x

def main():
	nr = int(input())
	for _ in range(nr):
		(_, x) = [int(s) for s in input().split(' ')]
		a = [int(s) for s in input().split(' ')]
		print(solve(a, x))
main()


for test in range(int(input())):
	(n, k) = map(int, input().split())
	lt = list(map(int, input().split()))[:n]
	i = 0
	while k >= 0:
		i += 1
		if i not in lt:
			k -= 1
	print(i - 1)


t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().strip().split(' '))
	a = set(list(map(int, input().strip().split(' '))))
	count = x + 1
	r = 0
	for i in range(1, len(a) + x + 2):
		if i in a:
			r += 1
			continue
		else:
			count -= 1
		r += 1
		if not count:
			break
	print(r - 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(set(a))
	c = max(b)
	d = 0
	for i in range(1, c + k + 1):
		if i not in b:
			if d == k:
				i -= 1
				break
			d += 1
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = sorted(set(map(int, input().split())))
	cur = 0
	for v in x:
		if v - cur > k + 1:
			cur += k
			break
		else:
			k -= v - cur - 1
			cur = v
	else:
		cur += k
	print(cur)


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = []
	for i in range(100):
		b.append(-1)
	for i in a:
		b[i - 1] = 1
	i = 0
	while i < 100 and x > 0:
		if b[i] == -1:
			x -= 1
		i += 1
	while i < 100 and b[i] == 1:
		i += 1
	print(i + x)


t = int(input())

def check(arr, ans, x):
	temp = set(arr)
	c = 0
	for item in range(1, ans + 1):
		if item not in temp:
			c += 1
	return c <= x
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = sorted([int(x) for x in input().split()])
	ans = 201
	while ans >= 1:
		if check(arr, ans, x):
			break
		ans -= 1
	print(ans)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, x) = (int(x) for x in stdin.readline().split())
	hash_set = set()
	for i in stdin.readline().split():
		hash_set.add(int(i))
	for i in range(1, n + x + 1):
		if i not in hash_set:
			x -= 1
		if x == -1:
			print(i - 1)
			break
	else:
		print(i)


from sys import stdin
rInt = lambda : int(stdin.readline().strip('\n'))
rIntArray = lambda : [int(x) for x in stdin.readline().split()]
rString = lambda : stdin.readline().strip('\n')
rStrArray = lambda : [x for x in stdin.readline().split()]
for _ in range(rInt()):
	(n, x) = rIntArray()
	a = set(rIntArray())
	for i in range(1, 1000):
		if x == 0 and i not in a:
			print(i - 1)
			break
		elif i not in a:
			x -= 1


t = int(input())
for T in range(t):
	(n, x) = [int(i) for i in input().split()]
	vietos = []
	for i in range(1000):
		vietos.append(0)
	for i in input().split():
		vietos[int(i) - 1] = 1
	o = 0
	kur = 0
	while o <= x:
		if vietos[kur] == 0:
			o += 1
		kur += 1
	print(kur - 1)


def get():
	return int(input())
t = get()
while t > 0:
	(n, x) = map(int, input().split())
	s = set()
	a = list(map(int, input().split()))
	for i in a:
		s.add(i)
	res = 0
	for i in range(1, 201):
		if i not in s:
			x = x - 1
		if x < 0:
			break
		res = max(res, i)
	print(res)
	t = t - 1


def solve(n, x, a):
	a.sort()
	count = 1
	for i in a:
		if i == count:
			count += 1
		elif i > count:
			if x >= i - count:
				x -= i - count
				count = i + 1
			else:
				break
	print(count - 1 + x)
t = int(input())
for i in range(0, t):
	line1 = list(map(lambda x: int(x), input().split()))
	n = line1[0]
	x = line1[1]
	a = list(map(lambda x: int(x), input().split()))
	solve(n, x, a)


c = int(input())
for i in range(c):
	(n, x) = map(int, input().split())
	a = map(int, input().split())
	a = set(a)
	a = list(a)
	a.sort()
	n = len(a)
	count = 0
	i = 1
	while True:
		if i in a:
			count += 1
		elif x > 0:
			x -= 1
			count += 1
		else:
			break
		i += 1
	print(count)


a = input()
d = []
nx = []
vs = []
for i in range(int(a)):
	nx.append(input(''))
	d.append(input(''))
	d[i] = d[i].split(' ')
	nx[i] = nx[i].split(' ')
	v = 0
	place = 1
	xo = int(nx[i][1])
	while xo > 0:
		cantfind = True
		while cantfind:
			cantfind = False
			for k in range(len(d[i])):
				if int(d[i][k]) == place:
					v = v + 1
					place = place + 1
					cantfind = True
		xo = xo - 1
		v = v + 1
		place = place + 1
		cantfind = True
		while cantfind:
			cantfind = False
			for k in range(len(d[i])):
				if int(d[i][k]) == place:
					v = v + 1
					place = place + 1
					cantfind = True
	vs.append(v)
for vi in vs:
	print(vi)


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	ar = set(lst)
	print(list(set(range(1, 205)) - ar)[x] - 1)


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	l = sorted(l)
	x = n + d
	a = [0] * 1001
	ans = -1
	for i in range(n):
		a[l[i]] = 1
	for i in range(1, 10001):
		if a[i] == 0:
			if d == 0:
				ans = i - 1
				break
			else:
				d -= 1
		if a[i] == 1:
			continue
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = input().split()
	ranks = input().split()
	count = 0
	temp = 1
	ranks = list(set(ranks))
	ranks.sort()
	for ele in range(len(ranks)):
		ranks[ele] = int(ranks[ele])
	while count < int(x):
		if temp in ranks:
			temp += 1
		else:
			count += 1
			ranks.append(temp)
	ranks.sort()
	prev = 0
	j = len(ranks)
	k = 1
	while k < j:
		if ranks[k] == ranks[prev] + 1:
			prev += 1
			k += 1
		else:
			break
	print(k)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	li = list(map(int, input().split()))
	li = set(li)
	nm = 0
	while x >= 0:
		nm += 1
		if not nm in li:
			x -= 1
	print(nm - 1)


t = int(input())
for i in range(t):
	(n, x) = input().split(' ')
	(n, x) = (int(n), int(x))
	array = list(map(int, input().split(' ')))
	array = set(array)
	j = 1
	while x != 0:
		if j in array:
			j += 1
			continue
		else:
			array.add(j)
			x -= 1
			j += 1
	answer = 0
	k = 1
	while True:
		if k in array:
			answer += 1
			k += 1
		else:
			break
	print(answer)


a = int(input())
for j in range(0, a):
	b = input().split()
	c = input().split()
	d = set(c)
	count = 0
	flag = 0
	for i in range(1, len(d) + int(b[1]) + 1):
		if str(i) not in d:
			if count == int(b[1]):
				flag = 1
				break
			count = count + 1
	if flag == 1:
		print(i - 1)
	else:
		print(i)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	i = 1
	while True:
		if i in a:
			i += 1
			continue
		elif x > 0:
			x -= 1
		else:
			v = i - 1
			break
		i += 1
	print(v)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		ar = inpt()
		ar = set(ar)
		for i in ar:
			if i <= k:
				k += 1
		for i in ar:
			if i - k == 1:
				k += 1
		print(k)
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 resolve(n, x, pos):
	place_max = 1
	while True:
		if place_max not in pos:
			if x == 0:
				return place_max - 1
			x -= 1
		place_max += 1
tests = int(input())
for test in range(tests):
	param = [int(i) for i in input().split()]
	positions = [int(i) for i in input().split()]
	print(resolve(param[0], param[1], positions))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	r = {}
	for i in a:
		r[i] = 1
	i = 1
	ans = i
	while 1:
		if r.get(i) == None:
			if x > 0:
				x -= 1
			else:
				ans = i - 1
				break
		i += 1
	print(ans)


def DreammoonAndRankingColection(n, x, data):
	idRoom = 0
	while x > 0:
		idRoom += 1
		if idRoom not in data:
			x -= 1
	while idRoom + 1 in data:
		idRoom += 1
	return idRoom
t = int(input())
for i in range(t):
	(n, x) = input().split()
	data = input().split()
	n = int(n)
	x = int(x)
	for i in range(data.__len__()):
		data[i] = int(data[i])
	print(DreammoonAndRankingColection(n, x, data))


n = int(input())
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	e = 0
	for j in range(1, 10000):
		if j in c:
			pass
		else:
			e = e + 1
			c.append(j)
		if e == b:
			break
	c = sorted(set(c))
	f = -1
	for j in range(0, len(c) - 1):
		if c[j + 1] - c[j] <= 1:
			pass
		else:
			f = c[j]
			break
	if f == -1:
		print(c[len(c) - 1])
	else:
		print(f)


R = lambda : map(int, input().split())
(t,) = R()
for _ in range(t):
	(n, x) = R()
	a = [1] * 205
	i = s = 0
	for y in R():
		a[y] = 0
	while s < x + 1:
		i += 1
		s += a[i]
	print(i - 1)


import sys
import math
input = sys.stdin.readline
t = int(input())
for ti in range(1, t + 1):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	cnt = [0] * 10010
	for i in a:
		cnt[i] += 1
	(res, added, i) = (101, 0, 0)
	while added < x:
		i += 1
		if cnt[i] == 0:
			added += 1
	while cnt[i + 1] > 0:
		i += 1
	print(i)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(set(map(int, input().split()))))
	v = []
	for i in range(1, len(a) + 1):
		if a[i - 1] - i > x:
			break
		else:
			v.append(a[i - 1] + x - (a[i - 1] - i))
	if v:
		print(max(v))
	else:
		print(x)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = set(arr)
	mx = n + x + 1
	ans = -1
	for idx in range(1, mx):
		if idx in s:
			ans = idx
			continue
		if x > 0:
			x -= 1
			ans = idx
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = set(A)
	B = list(B)
	B.sort()
	d = 0
	for i in range(1, B[-1] + 1):
		if i not in B:
			x -= 1
			B.append(i)
		if x == 0:
			d = i + 1
			break
	B.sort()
	for i in range(1, B[-1] + 1):
		if i in B:
			ans = i
		else:
			break
	if x != 0:
		print(B[-1] + x)
	else:
		print(ans)


cases = int(input())
for case in range(cases):
	(n, x) = list(map(int, input().split(' ')))
	sequence = set(map(int, input().split(' ')))
	result = 1
	while x > 0 or result in sequence:
		if result not in sequence:
			x -= 1
		result += 1
	print(result - 1)


testes = int(input())
for i in range(testes):
	(n, x) = list(map(int, input().split(' ')))
	posicoes = list(map(int, input().split(' ')))
	posicoes.sort()
	lista = list(set(posicoes))
	final = [0 for a in range(n + x)]
	tamanho = n + x
	for a in range(1, tamanho + 1):
		if a not in lista:
			lista.append(a)
			lista.sort()
			x -= 1
			if x == 0:
				flag = False
				for b in range(1, len(lista)):
					if lista[b - 1] + 1 < lista[b]:
						print(lista[b - 1])
						flag = True
						break
				if not flag:
					print(len(lista))
				break


t = int(input())
for zz in range(t):
	i = input().split()
	n = int(i[0])
	x = int(i[1])
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	i = 1
	while x >= 0:
		if i not in a:
			x -= 1
		i += 1
	print(i - 2)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(set(a))
	for i in range(1, 202):
		if i not in a:
			x -= 1
			if x < 0:
				break
		ans = i
	print(ans)


t = int(input())
for tt in range(t):
	(n, x) = input().split()
	a = input().split()
	x = int(x)
	for i in range(1, 300):
		if x == 0 and (not str(i) in a):
			print(str(i - 1))
			break
		if not str(i) in a:
			if x > 0:
				x = x - 1
				a = a + [str(i)]


t = int(input())
arr = []
for _ in range(t):
	(n, x) = map(int, input().split())
	lst = set(map(int, input().split()))
	temp = x + n
	prev = 0
	for i in range(1, temp + 1):
		if i not in lst:
			if x == 0:
				break
			else:
				x -= 1
		prev = i
	arr.append(prev + x)
for i in arr:
	print(i)


t = int(input())
for i in range(t):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	a = set(a)
	a = list(a)
	a.sort()
	v = 0
	counter = 0
	for j in a:
		nexus = j - counter
		if nexus > 0:
			if x >= nexus - 1:
				v += nexus
				x = x - (nexus - 1)
				counter = j
			else:
				v += x
				x = 0
				break
	if x != 0:
		print(v + x)
	else:
		print(v)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	dit = {}
	for i in a:
		dit[i] = 1
	(cnt, rm) = (0, 0)
	for i in range(1, n + k + 2):
		if dit.get(i) == None:
			if cnt == k:
				rm = i
				break
			else:
				cnt += 1
	print(rm - 1)
	t -= 1


for i in range(int(input())):
	(n, x) = map(int, input().split())
	li = [int(i) for i in input().split()]
	max = 1000
	v = [0] * max
	for i in li:
		v[i] += 1
	cont = 0
	for i in range(1, max):
		if v[i] == 0:
			cont += 1
			v[i] = 1
		if cont == x:
			for j in range(i, max):
				if v[j] == 0:
					print(j - 1)
					break
			break


test = int(input())
for i in range(test):
	(n, k) = [int(j) for j in input().split()]
	nums = [int(p) for p in input().split()]
	s = n + k
	for j in range(n + k, 0, -1):
		v = 0
		for t in range(1, j + 1):
			if t not in nums:
				v += 1
		if v <= k:
			print(j)
			break


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(a)
	b = sorted(b)
	v = 1
	f = 0
	while x > 0:
		if v in b:
			v = v + 1
			continue
		else:
			b.append(v)
			v = v + 1
			x = x - 1
	b = sorted(b)
	for i in range(len(b)):
		if i + 1 != b[i]:
			f = 1
			break
	if f:
		print(b[i - 1])
	else:
		print(b[i])


t = int(input())
for tt in range(t):
	(n, x) = map(int, input().split())
	p = [False] * 201
	for i in map(int, input().split()):
		p[i - 1] = True
	for i in range(201):
		if not p[i] and x == 0:
			print(i)
			break
		if not p[i]:
			x -= 1


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	B = set(A)
	ans = 0
	for i in range(1, 300):
		if i not in B:
			if x <= 0:
				break
			x -= 1
			ans += 1
		else:
			ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = [int(num) for num in input().split()]
	arr = [int(num) for num in input().split()]
	i = 1
	while x >= 0:
		if i in arr:
			i += 1
		else:
			if x != 0:
				i += 1
			x -= 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	v = 0
	cur = 1
	a = list(a)
	a.sort()
	for i in range(len(a)):
		if a[i] == cur:
			v += 1
			cur += 1
		elif x > 0:
			while x > 0 and a[i] != cur:
				x -= 1
				v += 1
				cur += 1
			if a[i] == cur:
				v += 1
				cur += 1
		else:
			break
	while x > 0:
		x -= 1
		v += 1
	print(v)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	v = 0
	for k in range(1, n + x + 1):
		if k in a:
			v += 1
		elif x > 0:
			v += 1
			x -= 1
		elif x == 0:
			break
	print(v)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	aa = sorted(set(map(int, input().split())))
	nm = 0
	for i in range(1, 1000):
		if i not in aa:
			nm += 1
		if nm == x:
			i += 1
			break
	aa = set(aa)
	while i in aa:
		i += 1
	print(i - 1)


import collections

class Solution:

	def solve(self, n, x, arr):
		arr = set(arr)
		elem = 1
		while True:
			if elem not in arr:
				x -= 1
			if x < 0:
				break
			elem += 1
		return elem - 1
sol = Solution()
t = int(input().strip())
for i in range(t):
	[n, x] = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	print(sol.solve(n, x, arr))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = set(l)
	c = 0
	f = False
	for i in range(1, 101):
		if i not in s:
			c += 1
		if c == x:
			ans = i
			f = True
			break
	if f:
		for i in range(ans + 1, 101):
			if i in s:
				ans = i
			else:
				break
		print(ans)
	else:
		x = x - c
		ans = 100 + x
		print(ans)


m = 10 ** 9 + 7
t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	l = sorted(list(map(int, input().split())))
	ii = 1
	i = 0
	while i < n and x > 0:
		if l[i] == ii:
			while i < n and l[i] == ii:
				i += 1
			ii += 1
			continue
		else:
			x -= 1
			if x > 0:
				ii += 1
			continue
	if x > 0:
		ii -= 1
		while x > 0:
			ii += 1
			x -= 1
	else:
		while ii + 1 in l:
			ii += 1
	print(ii)


from math import ceil, gcd, floor
from collections import deque, defaultdict
from heapq import heappush as hpush, heappop as hpop, heapify
from functools import lru_cache
testcase = int(input())
for _ in range(testcase):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set(a)
	for i in range(1, 100000):
		if i not in s and k == 0:
			print(i - 1)
			break
		if i not in s:
			k -= 1


import sys
readLine = lambda : sys.stdin.readline()
readInt = lambda : int(sys.stdin.readline())
readInts = lambda : [int(x) for x in sys.stdin.readline().split(' ')]

def main():
	solns = []
	t = readInt()
	for _ in range(t):
		(n, x) = readInts()
		a = readInts()
		a.sort()
		greatest = 0
		for v in range(1, n + x + 1):
			contests = set(range(1, v + 1))
			sub = {z for z in a if z <= v + x}
			if len(contests - sub) <= x:
				greatest = len(contests)
		solns.append(greatest)
	print('\n'.join((str(s) for s in solns)))
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	arr = list(set(arr))
	arr.sort()
	k = len(arr)
	s = 1
	i = 0
	while i < k:
		if arr[i] == s:
			s += 1
			i += 1
		elif x == 0:
			break
		else:
			x -= 1
			s += 1
	print(s + x - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 1
	while x > 0 or i in a:
		if i in a:
			i += 1
			continue
		else:
			i += 1
			x -= 1
	print(i - 1)


import sys
tests = int(sys.stdin.readline())
testcount = 0
while testcount < tests:
	(pre, post) = map(int, input().split())
	arr = sys.stdin.readline().split()
	i = 1
	while post > -1:
		if str(i) not in arr:
			post -= 1
		i += 1
	print(i - 2)
	testcount += 1


t = int(input())
for z in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	w = [False for i in range(300)]
	for i in a:
		w[i] = True
	ind = 0
	while x >= 0:
		if w[ind + 1] == False:
			if x > 0:
				x -= 1
				ind += 1
			else:
				break
		else:
			ind += 1
	print(ind)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	vis = [0] * 105
	for i in range(n):
		vis[a[i]] = 1
	res = 0
	for i in range(1, 101):
		if vis[i] == 0:
			x -= 1
		if x < 0:
			break
		res += 1
	if x > 0:
		res += x
	print(res)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l = list(set(l))
	for i in range(1, 1000):
		if i not in l and x > 0:
			l.append(i)
			x -= 1
	l.sort()
	for i in range(len(l)):
		if i != len(l) - 1:
			if l[i] != l[i + 1] - 1:
				print(i + 1)
				break
		else:
			print(l[len(l) - 1])


for _ in range(int(input())):
	x = [int(e) for e in input().split()][1]
	w = set([int(i) for i in input().split()])
	cur = 1
	wynik = []
	while True:
		if cur not in w:
			if x == 0:
				break
			x -= 1
		cur += 1
	print(cur - 1)


t = int(input())
for i in range(t):
	nx = input().split()
	n = int(nx[0])
	x = int(nx[1])
	a = [int(x) for x in input().split()]
	a = set(a)
	c = 0
	for i in range(1, 101 + x):
		if not i in a and x == 0:
			break
		if not i in a:
			x -= 1
		c = i
	print(c)


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = map(int, input().split())
	places = defaultdict(bool)
	for place in a:
		places[place] = True
	falses = 0
	i = 1
	while falses <= x:
		if not places[i]:
			falses += 1
		i += 1
	print(i - 2)


t = int(input())
for i in range(t):
	res = 0
	f = False
	(n, x) = map(int, input().split())
	a = sorted(set([int(j) for j in input().split()]))
	d = dict(zip(a, [True for j in range(len(a))]))
	k = 0
	for j in range(1, max(a) + 1):
		if j not in d:
			k += 1
		if k == x:
			res = max(res, j)
			f = True
	if not f:
		while True:
			j += 1
			k += 1
			if k == x:
				res = j
				break
	print(res)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	i = 0
	while True:
		i += 1
		if i not in a and x != 0:
			x -= 1
		elif i not in a and x == 0:
			break
	print(i - 1)


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	G = [0 for i in range(500)]
	for i in A:
		G[i] = 1
	A = list(set(A))
	A.sort()
	i = 1
	fc = 0
	while k != -1:
		if G[i] == 1:
			fc = fc + 1
		elif G[i] == 0 and k != 0:
			fc = fc + 1
			k = k - 1
		else:
			k = k - 1
		i = i + 1
	print(fc)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	check = [0] * 101
	ma = 0
	for i in x:
		ma = max(ma, i)
		check[i] = 1
	(ans, mode) = (ma, 0)
	for i in range(1, ma + 1):
		if mode == 1:
			if check[i] == 0:
				ans = i - 1
				break
		else:
			if check[i] == 0:
				k -= 1
			if k == 0:
				mode = 1
	if k > 0:
		ans += k
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	l = list(map(int, input().split()))
	l = set(l)
	l = list(l)
	l.sort()
	ans = 0
	for i in l:
		if i - ans == 1:
			ans += 1
		elif x <= 0:
			break
		else:
			gap = i - ans - 1
			if x >= gap:
				x = x - gap
				ans = i
			else:
				ans = ans + x
				x = 0
	print(ans + x)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

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

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

def LS():
	return sys.stdin.readline().split()

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

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

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, x) = LI()
		a = LI()
		r = [False] * 202
		for c in a:
			r[c] = True
		for i in range(1, 202):
			if not r[i]:
				x -= 1
				if x < 0:
					rr.append(i - 1)
					break
	return JA(rr, '\n')
print(main())


import itertools
count_tests = int(input())
for i in range(count_tests):
	(n, x) = input().split(' ')
	n = int(n)
	x = int(x)
	places = [int(place) for place in input().split(' ')]
	not_places = sorted(set(range(1, n + x + 1)) - set(places))
	max_not_places = list(itertools.islice(not_places, x))[-1]
	v = max_not_places + 1
	while v in places:
		v += 1
	print(v - 1)


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


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = sorted(list(map(int, input().split())))
	c = []
	i = 1
	while 1:
		if i in arr:
			i = i + 1
			continue
		else:
			c.append(i)
			x = x - 1
			i = i + 1
		if x == 0:
			break
	arr = sorted(list(set(arr + c)))
	cc = 0
	for j in range(1, len(arr)):
		if arr[j] - 1 == arr[j - 1]:
			cc = cc + 1
			continue
		else:
			break
	print(cc + 1)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	mas = sorted(list(map(int, input().split())))
	mas.append(-3)
	otv = 0
	cri = 0
	for m in range(1, 20000):
		if m == mas[cri]:
			while mas[cri] == mas[cri + 1]:
				cri += 1
			cri += 1
			otv = m
			continue
		if x == 0:
			break
		x -= 1
		otv = m
	print(otv)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 0
	n = len(arr)
	i = 0
	while x >= 0 and i <= n:
		if ans + 1 not in arr:
			x -= 1
		ans += 1
	print(ans + x)


def ntvdm():
	n = int(input())
	for _ in range(n):
		(n, x) = map(int, input().split())
		arr = set(map(int, input().split()))
		i = 0
		while 1:
			i += 1
			if i in arr:
				continue
			if x == 0:
				break
			x -= 1
		print(i - 1)
ntvdm()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	liste = list(map(int, input().split()))
	vis = [0 for i in range(202)]
	for i in range(n):
		vis[liste[i]] = 1
	count = 0
	for i in range(1, 202):
		if count == x:
			break
		if not vis[i]:
			vis[i] = 1
			count += 1
	maxi = 0
	for i in range(1, 202):
		if vis[i]:
			maxi = max(maxi, i)
		else:
			break
	print(maxi)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar = set(ar)
	ans = 1
	for i in range(1, 1000):
		if x == 0:
			continue
		if i not in ar:
			x -= 1
			ar.add(i)
	i = 1
	while i in ar:
		i += 1
	print(i - 1)


t = int(input())

def solve():
	mark = [False] * 201
	for i in a:
		mark[i] = True
	ans = 1
	for i in range(1, 201):
		req = x
		for j in range(1, i + 1):
			if not mark[j]:
				if req > 0:
					req -= 1
				else:
					return ans
			ans = j
	return ans
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(solve())


for i in range(int(input())):
	(n, x) = map(int, input().split())
	y = [int(w) for w in input().split()]
	z = sorted(list(set(map(int, y))))
	h = [0 for t in range(250)]
	for j in range(len(z)):
		h[z[j] - 1] = 1
	ans = 0
	for l in range(len(h)):
		if h[l] != 1 and ans < x:
			ans += 1
			h[l] = 1
	for q in range(len(h)):
		if h[q] != 1:
			break
	print(q)


for _ in range(int(input())):
	flags = [False] * 100
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	for e in arr:
		flags[e - 1] = True
	res = -1
	for (i, f) in enumerate(flags):
		if not f:
			if x == 0:
				res = i
				break
			x -= 1
	if res == -1:
		res = 100
	print(res + x)


import sys
input = sys.stdin.readline
inputt = lambda : range(int(input()))
inputi = lambda : map(int, input().split())
from math import *
from heapq import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict
for _ in inputt():
	(n, x) = inputi()
	A = sorted(list(inputi())) + [inf]
	(i, d) = (0, 0)
	while i < n + 1 and (A[i] <= d + 1 or x):
		if A[i] < d + 1:
			i += 1
		elif A[i] == d + 1:
			i += 1
			d += 1
		else:
			x -= 1
			d += 1
	print(d + x)


import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	c = 0
	for i in range(1, n + x + 1):
		if i not in arr and c < x:
			arr.append(i)
			c = c + 1
	c = 0
	for i in range(1, n + x + 1):
		if i not in arr:
			break
		else:
			c = i
	print(c)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	free_pos = [True] * 200
	for pos in map(int, input().split()):
		free_pos[pos - 1] = False
	last = 100
	for i in range(100):
		if free_pos[i]:
			x -= 1
			if x == 0:
				last = i
				break
	if x > 0:
		print(100 + x)
	else:
		result = 100
		for i in range(last + 1, 100):
			if free_pos[i]:
				result = i
				break
		print(result)


t = int(input())
for _ in range(t):
	c = 0
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	p = 0
	while x > 0:
		p += 1
		if p in a:
			c += 1
		else:
			x -= 1
			c += 1
	for i in a:
		p += 1
		if p in a:
			c += 1
		else:
			break
	print(c)


from math import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
inp = lambda : int(input())
li = lambda : list(map(int, input().split()))
ls = lambda : list(input())
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def solve():
	for _ in range(inp()):
		(n, x) = li()
		a = sorted(li())
		i = 1
		while x >= 0:
			if i not in a:
				x -= 1
			i += 1
		print(i - 2)
solve()


t = int(input())
for _ in range(t):
	(_, x) = list(map(int, input().split(' ')))
	a = set(list(map(int, input().split(' '))))
	v = 0
	for i in range(1, max(a) + x + 1):
		if i in a:
			v = i
			continue
		elif x == 0:
			break
		else:
			v = i
			x -= 1
	print(v)


def get_max_rank(contest_ranks, rem_contest):
	elements = []
	ele = 1
	while True:
		if rem_contest > 0 and ele not in contest_ranks:
			rem_contest -= 1
			ele += 1
		elif ele in contest_ranks:
			ele += 1
		else:
			return ele - 1
tot_tc = int(input())
for i in range(tot_tc):
	(_, rem_contest) = [int(ele) for ele in input().split()]
	contest_ranks = {int(ele) for ele in input().split()}
	print(get_max_rank(contest_ranks, rem_contest))


import sys
input = sys.stdin.buffer.readline
t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = list(set(arr))
	k = 1
	i = 0
	ans = -1
	arr.sort()
	while i < len(arr) and x >= 0:
		if arr[i] != k:
			x -= 1
			k += 1
			if x >= 0:
				ans = k
		else:
			k += 1
			i += 1
			ans = k
	if x <= 0:
		if ans == -1:
			print('0')
		else:
			print(ans - 1)
	else:
		print(arr[-1] + x)


from sys import stdin, stdout
for _ in range(int(stdin.readline().strip())):
	(n, x) = list(map(int, stdin.readline().strip().split()))
	a = list(map(int, stdin.readline().strip().split()))
	a = sorted(list(set(a)))
	for i in a:
		if i <= x + 1:
			x += 1
	print(x)


T = int(input())
for t in range(T):
	(n, x) = map(int, input().split())
	b = list(map(int, input().split()))
	a = [False] * 100
	for i in range(n):
		a[b[i] - 1] = True
	(i, c) = (0, 0)
	y = x
	while x > -1 and i < 100:
		if not a[i]:
			x -= 1
		i += 1
		c += 1
	print(c + x)
	t += 1


import math
import string
a = int(input())
for i in range(a):
	b = input().split(' ')
	n = int(b[0])
	x = int(b[1])
	c = input().split(' ')
	counter = 0
	v = 1
	while counter < x:
		if c.count(str(v)) == 0:
			counter = counter + 1
			if counter >= x:
				while c.count(str(v + 1)) != 0:
					v = v + 1
				break
			v = v + 1
		else:
			v = v + 1
	print(v)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 1
	while x != 0:
		if i not in a:
			x = x - 1
		i = i + 1
	while True:
		if i in a:
			i = i + 1
		else:
			break
	print(i - 1)


def solve():
	(n, x) = [int(v) for v in input().split()]
	places = {int(v) for v in input().split()}
	idx = 0
	while idx + 1 in places or x > 0:
		if idx + 1 not in places:
			x -= 1
		idx += 1
	print(idx)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for test in range(t):
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	arr = list(map(int, input().split()))
	counter = 1
	while x >= 0:
		if counter not in arr:
			x -= 1
		counter += 1
	print(counter - 2)


t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr2 = [0] * 250
	for i in range(n):
		arr2[arr[i]] = 1
	i = 1
	while x > 0 or arr2[i] == 1:
		if arr2[i] != 1:
			x -= 1
		i += 1
		if i == 250:
			break
	print(i - 1)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = set([int(i) for i in input().split()])
	now = set()
	ans = 0
	for i in range(1, max(l) + x + 1):
		now.add(i)
		if len(l & now) >= i - x:
			ans = i
	print(ans)


import math
lower = int(input(''))
for i in range(0, lower):
	inp = list(map(int, input().split()))
	n = inp[0]
	x = inp[1]
	arr = list(map(int, input().split()))
	k = 0
	while k <= x:
		k += 1
		if k in arr:
			x = x + 1
	print(k - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(set(map(int, input().split())))
	m = [0 for bi in range(1000)]
	for t in l:
		m[t - 1] = 1
	for i in range(len(m)):
		if m[i] == 0 and x > 0:
			m[i] = 1
			x -= 1
	f = 0
	for t in m:
		if t == 0:
			break
		f += 1
	print(f)


for j in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(j) for j in input().split()]
	nu = 1
	cou = 0
	while cou < x:
		while nu in a:
			nu += 1
		cou += 1
		if cou < x:
			nu += 1
	while nu + 1 in a:
		nu += 1
	print(nu)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	items = set(map(int, input().split()))
	items = list(items)
	res = 1
	while res in items or x > 0:
		if res not in items:
			x -= 1
		res += 1
	print(res - 1)


t = int(input())
print()
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	flag = [False] * 201
	for i in range(n):
		flag[a[i]] = True
	flag[0] = True
	fpos = []
	for i in range(1, 201):
		if not flag[i]:
			fpos.append(i)
	if x >= len(fpos):
		end = 200
	else:
		end = fpos[x] - 1
	print(end)


for t in range(int(input())):
	(n, x) = [int(s) for s in input().split()]
	memo = [1] * 202
	memo[0] = 0
	A = [int(s) for s in input().split()]
	for a in A:
		memo[a] = 0
	i = 1
	while x >= memo[i]:
		x -= memo[i]
		i += 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(set(map(int, input().split())))
	a.sort()
	n = len(a)
	(c, b) = (0, 200)
	for i in range(1, 202):
		if a[c] != i:
			if x != 0:
				x -= 1
			else:
				b = i - 1
				break
		else:
			if c + 1 == n:
				b = a[c] + x
				break
			c += 1
	print(b)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	count = 0
	done = False
	while not done:
		for i in range(1, max(a)):
			if not i in a:
				count += 1
		if count == x:
			print(max(a))
			done = True
		elif count < x:
			print(max(a) + (x - count))
			done = True
		else:
			count = 0
			a[a.index(max(a))] = 0


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split(' '))
	s = set(map(int, input().split(' ')))
	i = 0
	while x >= 0:
		if i + 1 not in s:
			if x == 0:
				break
			x -= 1
		i += 1
	print(i)


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 ti in range(t):
	(a, b) = (int(i) for i in input().split(' '))
	li = [int(i) for i in input().split(' ')]
	li.sort()
	beg = 0
	for i in li:
		if i == beg + 1:
			beg += 1
		elif i > beg:
			if b == 0:
				break
			else:
				while i != beg + 1 and b:
					b -= 1
					beg += 1
				if i == beg + 1:
					beg += 1
	beg += b
	print(beg)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	r = list(sorted(set(a)))
	for i in range(1, 100000):
		if x == 0:
			break
		if i in a:
			continue
		else:
			a.append(i)
			x -= 1
	a = sorted(list(set(a)))
	q = 0
	for i in range(1, 1000000):
		if i in a:
			continue
		else:
			q = i - 1
			break
	print(q)


for i in range(int(input())):
	(n, x) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	r = 0
	for l in range(1, 1000):
		if l in a:
			r += 1
			continue
		elif x > 0:
			r += 1
			x -= 1
		else:
			break
	print(r)


def solve():
	(n, x) = input().split(' ')
	n = int(n)
	x = int(x)
	values = [int(i) for i in input().split(' ')]
	values = list(dict.fromkeys(values))
	values = sorted(values)
	last = 0
	ans = 0
	for i in values:
		delta = i - last - 1
		last = i
		if delta < x:
			x = x - delta
			ans = i
		else:
			ans = ans + x
			x = 0
			break
	if x > 0:
		ans = ans + x
		print(ans)
	else:
		while ans + 1 in values:
			ans += 1
		print(ans)
t = input()
for i in range(int(t)):
	solve()


for _ in range(int(input())):
	(m, n) = input().split()
	m = int(m)
	n = int(n)
	l = list(map(int, input().split()))
	i = 1
	cnt = 0
	while cnt < n and i <= m + n + 1:
		if i not in l:
			cnt += 1
		i += 1
	if cnt == n:
		while i <= m + n + 1:
			if i not in l:
				break
			i += 1
	print(i - 1)


t = int(input())
for i in range(t):
	m = list(map(int, input().split()))
	l = []
	num = list(map(int, input().split()))
	for i in num:
		l.append(i)
	l = sorted(l)
	bol = True
	cnt = 0
	mm = 1
	while bol:
		if mm not in l:
			cnt = cnt + 1
		if cnt == m[1]:
			bol = False
		mm = mm + 1
	mm = mm - 1
	for i in range(len(l)):
		if l[i] > mm:
			if l[i] - mm == 1:
				mm = mm + 1
			else:
				break
	print(mm)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	lis = [0] * 300
	for i in range(n):
		lis[arr[i]] = 1
	i = 1
	while x != 0:
		if lis[i] == 0:
			lis[i] = 1
			x -= 1
		i += 1
	while True:
		if lis[i] == 0:
			break
		i += 1
	print(i - 1)


from sys import stdin, stdout
from collections import defaultdict, Counter
from functools import lru_cache
from math import gcd, floor, ceil

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

def iint():
	return int(stdin.readline().strip())

def istr():
	return stdin.readline().strip()
t = iint()
for _x in range(t):
	(n, x) = ilist()
	arr = set(ilist())
	i = 0
	while x:
		i += 1
		if i not in arr:
			arr.add(i)
			x -= 1
	while i in arr:
		i += 1
	print(i - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	i = 0
	while x != 0:
		l.sort()
		i += 1
		if i not in l:
			l.append(i)
			x -= 1
	f = 1
	y = 1
	ans = i
	while f == 1:
		if i + y in l:
			ans = i + y
			y += 1
		else:
			f = 0
	print(ans)


t = int(input())
for x in range(t):
	(n, m) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	l.sort()
	rank = 1
	while m != 0:
		if rank in l:
			rank += 1
		else:
			m -= 1
			rank += 1
	while rank in l:
		rank += 1
	print(rank - 1)


T = int(input())
for _ in range(0, T):
	(n, x) = map(int, input().split())
	s = [int(x1) for x1 in input().split()]
	kk = [0] * (n + 300)
	for i in range(0, len(s)):
		kk[s[i]] = 1
	ans = 1
	for i in range(1, n + 300):
		if kk[i] == 0:
			x -= 1
		if x == -1:
			ans = i - 1
			break
	print(ans)


from sys import stdin, stdout
import math
import heapq
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

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

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

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		(n, x) = In()
		arr = sorted(list(set(L())))
		for i in arr:
			if i <= x + 1:
				x += 1
		print(x)
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l = set(l)
	place = 1
	while x > 0:
		if place not in l:
			l.add(place)
			x -= 1
		if x != 0:
			place += 1
	while place in l:
		place += 1
	print(place - 1)


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def solve(a, x):
	num = 0
	numbers = []
	a = set(a)
	while (x > 0) | (num + 1 in a):
		num += 1
		if num in a:
			None
		else:
			x -= 1
	return str(num)
answers = []
t = int(input())
for i in range(t):
	(n, x) = to_list(input())
	a = to_list(input())
	answers.append(solve(a, x))
print('\n'.join(answers))


import sys
input = lambda : sys.stdin.readline().rstrip()

def I():
	return [int(iI) for iI in input().split()]

def II():
	return int(input())

def SI():
	return [i for i in input()]
for _ in range(II()):
	(n, x) = I()
	a = I()
	ans = [0] * 300
	for i in a:
		ans[i] = 1
	for i in range(1, len(ans)):
		if x == 0:
			break
		if ans[i] == 0:
			ans[i] = 1
			x -= 1
	print(ans[1:].index(0))


t = int(input())
for vbv in range(t):
	(n, x) = list(map(int, input().split(' ')))
	dat = list(map(int, input().split(' ')))
	dat.sort()
	c = 1
	cx = 0
	t = 0
	while True:
		if c in dat:
			c = c + 1
		else:
			cx = cx + 1
			if cx == x:
				while c + 1 in dat:
					c = c + 1
				break
			c = c + 1
	print(c)


from sys import stdin, stdout
import collections
import heapq
import itertools
import functools
import math
import operator
import string
ALPHABET = string.ascii_lowercase
DIGITS = string.digits

def read_line():
	return stdin.readline().strip()

def read_int():
	return int(read_line())

def read_arr():
	return read_line().split(' ')

def read_int_arr():
	return [int(x) for x in read_arr()]

def query_interactive(s):
	print(s)
	stdout.flush()

def solve():
	(n, x) = read_int_arr()
	a = read_int_arr() + [float('inf')]
	a.sort()
	cur_last = 0
	for v in a:
		if v == cur_last:
			continue
		if cur_last + x < v - 1:
			print(cur_last + x)
			return
		else:
			x -= v - cur_last - 1
			cur_last = v
	print(cur_last)

def main():
	T = 1
	T = read_int()
	for _ in range(T):
		solve()
main()


for i in range(int(input())):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	l = list(map(int, input().split()))
	l.sort()
	sum = 0
	i = 1
	while sum <= b:
		if i not in l:
			sum += 1
		i += 1
	print(i - 2)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(a)
	c = []
	for i in range(1, max(a) + 1):
		c.append(i)
	c = set(c)
	d = c - b
	if len(d) == 0:
		m = max(a) + x
	elif len(d) - x == 0:
		d = list(d)
		d.sort(reverse=True)
		m = max(a)
	elif len(d) - x > 0:
		d = list(d)
		d.sort(reverse=True)
		m = len(d) - x
		m = d[m - 1] - 1
	else:
		m = max(a) - (len(d) - x)
	print(m)


t = int(input())
for i in range(t):
	high = 0
	tot = 0
	ans = [int(x) for x in input().split(' ')]
	x = ans[1]
	arr = [int(x) for x in input().split(' ')]
	hashMap = {}
	for i in arr:
		if i not in hashMap:
			hashMap[i] = 1
	j = 1
	while x != 0:
		if j in hashMap:
			pass
		else:
			hashMap[j] = 1
			x -= 1
		j += 1
	k = 1
	while 1:
		if k in hashMap:
			high = k
		else:
			break
		k += 1
	print(high)


def answer(places, x):
	places = [0] + places
	places.sort()
	for i in range(1, len(places)):
		diff = places[i] - places[i - 1] - 1
		if diff == 0 or diff == -1:
			continue
		if diff > 0 and x == 0:
			return places[i - 1]
		if diff <= x:
			x -= diff
			continue
		if diff > x:
			return places[i - 1] + x
	return places.pop() + x
testCount = int(input())
for _ in range(testCount):
	(n, x) = map(int, input().split())
	places = list(map(int, input().split()))
	print(answer(places, x))


import sys
msg = sys.stdin.readlines()
l = []
for i in msg:
	a = list(map(int, i.split()))
	l.append(a)

def dorae_rank(n, x, l):
	a = 0
	while 1:
		a += 1
		if a not in l:
			x -= 1
		if x == 0:
			break
	v = a
	flag = 1
	b = a
	while flag == 1:
		b = b + 1
		if b in l:
			v += 1
		else:
			flag = 0
	return v
for i in range(l[0][0]):
	n = l[2 * i + 1][0]
	x = l[2 * i + 1][1]
	ls = l[2 * i + 2]
	print(dorae_rank(n, x, ls))


for _ in range(int(input())):
	(_, x) = map(int, input().split())
	abc = sorted(list(set(map(int, input().split()))))
	for i in abc:
		if i <= x:
			x += 1
		elif i == x + 1:
			x += 1
		else:
			break
	print(x)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	nums = set(map(int, input().split()))
	for i in range(1, 300):
		a = set(list(range(1, i)))
		if len(a - nums) <= x:
			ans = i - 1
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = set(a)
	a = list(a)
	a.sort()
	i = 1
	while x > 0:
		if i not in a:
			a.insert(i - 1, i)
			x -= 1
		i += 1
	for i in range(1, len(a)):
		if a[i] != a[i - 1] + 1:
			print(a[i - 1])
			break
	else:
		print(a[-1])


def fct():
	l = input().split(' ')
	n = int(l[0])
	x = int(l[1])
	liste = input().split(' ')
	for j in range(len(liste)):
		liste[j] = int(liste[j])
	liste.sort()
	prev = 0
	res = 0
	for el in liste:
		if el - prev > 1:
			if x - (el - prev - 1) < 0:
				return res + x
			else:
				res = el
				x = x - (el - prev - 1)
				prev = el
		else:
			prev = el
			res = el
	return res + x
t = int(input())
for i in range(t):
	print(fct())


for _ in range(int(input())):
	(x, y1) = map(int, input().split())
	y = list(map(int, input().split()))
	l = [0] * 1000000
	for j in y:
		l[j] += 1
	k = 0
	i = 1
	while k <= y1:
		if l[i] == 0:
			k += 1
		i += 1
	print(i - 2)


t = int(input())
for z in range(t):
	(n, m) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	f = 0
	l.sort(reverse=True)
	l = list(dict.fromkeys(l))
	for i in range(len(l)):
		if l[i] - 1 - (len(l) - i - 1) - m <= 0:
			print(l[i] + abs(l[i] - 1 - (len(l) - i - 1) - m))
			f = -1
			break
	if f == 0 and l[len(l) - 1] - 1 - m > 0:
		print(m)


from bisect import bisect_left, bisect_right
from sys import stdin, stdout, setrecursionlimit
from collections import Counter
input = lambda : stdin.readline().strip()
print = stdout.write
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ls = list(set(map(int, input().split())))
	ls.sort()
	k = 1
	i = 0
	n = len(ls)
	while m != 0 and i < n:
		if ls[i] != k:
			m -= 1
		else:
			i += 1
		k += 1
	M = k - 1 + m
	for i in ls:
		if i == M + 1:
			M += 1
	print(str(M) + '\n')


T = int(input())
for case in range(T):
	pass
	(m, n) = [int(x) for x in input().split()]
	s = set([int(x) for x in input().split(' ')])
	r = 1
	while n > 0:
		n -= 1
		while r in s:
			r += 1
		s.add(r)
		while r + 1 in s:
			r += 1
	print(r)


x = int(input())
for i in range(x):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	j = list(a)
	j.sort()
	max = 0
	for t in range(len(j)):
		if j[t] - 1 - t > m:
			break
		else:
			q = j[t] - 1 - t
			s = j[t] + (m - q)
			if s > max:
				max = s
	if j[0] - 1 - t > m:
		print(m)
	else:
		print(max)


t = int(input())
Ans = ''
for p in range(t):
	ans = 0
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	r = x
	i = 1
	while r > 0:
		if i in A:
			ans = i
		else:
			r -= 1
			ans = i
		i += 1
	while ans + 1 in A:
		ans += 1
	Ans += str(ans) + '\n'
print(Ans)


def NO():
	return print('NO')

def YES():
	return print('YES')

def INT():
	return int(input())

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

def STR():
	return input()

def MAP():
	return map(int, input().split())
for _ in range(INT()):
	(n, x) = MAP()
	a = LIST()
	a = set(a)
	ans = 1
	while x > 0:
		if ans not in a:
			ans += 1
			x = x - 1
		else:
			ans += 1
	ans -= 1
	while ans + 1 in a:
		ans += 1
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	arr = [0] * 201
	for i in range(n):
		arr[a[i]] += 1
	i = 1
	pos = 0
	while x > 0 and i <= 200:
		if arr[i] == 0:
			arr[i] += 1
			a.append(i)
			pos = i
			x = x - 1
		i += 1
	a.sort()
	ans = 0
	i = 0
	while i < len(a) - 1:
		diff = a[i + 1] - a[i]
		if diff != 0 and diff != 1:
			ans = a[i]
			break
		i += 1
	if ans == 0:
		print(a[len(a) - 1])
	else:
		print(ans)


def num_moves(n, nums, x):
	possible = []
	curr = 1
	while x > -1:
		if curr in nums:
			possible.append(curr)
		elif x != 0:
			possible.append(curr)
			x -= 1
		else:
			return len(possible)
		curr += 1
	return len(possible)
t = int(input())
ans = []
for i in range(t):
	(n, x) = [int(s) for s in input().split(' ')]
	nums = [int(s) for s in input().split(' ')]
	ans.append(num_moves(n, nums, x))
for i in range(t):
	print(ans[i])


a = int(input())
for _ in range(a):
	(n, x) = map(int, input().split())
	ar = sorted(list(map(int, input().split())))
	z = 0
	for i in range(n):
		if ar[i] - 1 <= x:
			if z != ar[i]:
				x += 1
				z = ar[i]
		else:
			break
	print(x)


t = int(input())
for i in range(0, t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	k = 0
	while x >= 0:
		k = k + 1
		while k in a:
			k = k + 1
		x = x - 1
	print(k - 1)


for _ in range(int(input())):
	c = 0
	(a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = list(set(arr))
	arr.sort()
	z = [i for i in range(1, a + b + 1)]
	for i in z:
		if b > 0:
			if i not in arr:
				b -= 1
				c += 1
			else:
				c += 1
		else:
			break
		x = i
	for j in arr:
		if x + 1 in arr:
			c += 1
			x += 1
		else:
			break
	print(c)


t = int(input())
ans = []
for z in range(t):
	k = list(map(int, input().split()))
	n = k[0]
	x = k[1]
	b = list(map(int, input().split()))
	v = 0
	while 1:
		v += 1
		if v in b:
			continue
		else:
			if x == 0:
				break
			x -= 1
	ans.append(v - 1)
for i in ans:
	print(i)


t = int(input())
for i in range(t):
	(n, x) = [int(i) for i in input().split()]
	a = set([int(i) for i in input().split()])
	s = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500}
	k = list(s - a)
	for i in range(x):
		k.pop(0)
	print(k[0] - 1)


from math import *
from copy import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(l, x):
	n = len(l)
	L = [0] * (max(l) + 1 + x)
	for i in l:
		L[i] = 1
	i = 1
	while x > 0 and i < len(L):
		if L[i] == 1:
			i += 1
		else:
			x -= 1
			L[i] = 1
			i += 1
	ans = 0
	for i in range(1, len(L)):
		if L[i] == 1:
			ans += 1
		else:
			break
	return ans
T = int(input())
for _ in range(T):
	(N, X) = list(map(int, stdin.readline().rstrip().split()))
	l = list(map(int, stdin.readline().rstrip().split()))
	print(solve(l, X))


for test in range(int(input())):
	A = list(map(int, input().split()))
	B = sorted(list(map(int, input().split())))
	dic = {}
	for element in B:
		dic.update({element: ''})
	num_in = 1
	cont = 0
	while cont < A[1]:
		if not num_in in dic:
			dic.update({num_in: ''})
			cont += 1
		num_in += 1
	while True:
		if num_in in dic:
			num_in += 1
		else:
			break
	print(num_in - 1)


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

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

def mdata():
	return map(int, data().split())
mod = int(1000000000.0 + 7)
for t in range(int(data())):
	(n, x) = mdata()
	dp = [0] * 1000
	A = list(mdata())
	for i in range(n):
		dp[A[i]] += 1
	cnt = 0
	for i in range(1, 1000):
		if dp[i] == 0:
			cnt += 1
		if cnt > x:
			break
	print(i - 1)


from math import ceil, sqrt, log, gcd

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

def si():
	return input()

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

def li():
	return list(mi())

def isprime(n):
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return 0
	return 1

def main():
	for _ in range(ii()):
		(n, k) = mi()
		a = li()
		a = list(set(a))
		a.sort()
		j = 0
		f = 0
		for i in range(1, 205):
			if j < len(a) and i == a[j]:
				j += 1
			else:
				k -= 1
			if k < 0:
				f = 1
				break
		if f == 1:
			print(i - 1)
		else:
			print(i + k)
main()


from sys import stdin, stdout
t = int(stdin.readline())
for i in range(t):
	(n, x) = map(int, stdin.readline().split())
	a = [int(i) for i in stdin.readline().split()]
	b = [0] * 1000
	for i in range(len(a)):
		b[a[i]] = 1
	i = 1
	while x > 0:
		if b[i] == 0:
			x -= 1
			b[i] = 1
		i += 1
	for i in range(1, len(b)):
		if b[i] == 0:
			print(i - 1)
			break


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	z = [0] * 1000
	for i in range(n):
		z[a[i]] = 1
	i = 0
	while 1:
		i += 1
		if not z[i]:
			if x == 0:
				break
			x -= 1
	print(i - 1)


from collections import Counter
for _ in range(0, int(input())):
	(n, x) = map(int, input().split())
	c = Counter(map(int, input().split()))
	i = 1
	while True:
		if c[i] < 1:
			if x > 0:
				x -= 1
			else:
				i -= 1
				break
		i += 1
	print(i)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import deque
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
t = ip()
for _ in range(t):
	(n, x) = inp()
	arr = list(inp())
	arr = sorted(list(set(arr)))
	ch = [False] * 202
	for i in arr:
		ch[i] = True
	arr = list(ch)
	for i in range(1, 202):
		if arr[i]:
			pass
		else:
			if x == 0:
				i -= 1
				break
			arr[i] = True
			x -= 1
	print(i)


import sys
from collections import Counter
from copy import deepcopy
for t in range(int(sys.stdin.readline().strip())):
	(n, x) = [int(j) for j in sys.stdin.readline().split()]
	l = [int(j) for j in sys.stdin.readline().split()]
	m = [0 for i in range(230)]
	for i in range(n):
		m[l[i]] = 1
	ans = x
	ct = 0
	for i in range(1, len(m)):
		if m[i] > 0:
			if ct <= x:
				ans = max(x - ct + i, ans)
		else:
			ct += 1
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	r = list(set(list(map(int, input().split()))))
	r.sort()
	n = len(r)
	temp = 0
	i = 0
	while x >= 0 and n > i:
		if r[i] - temp - 1 > x:
			temp += x
			x = 0
			break
		else:
			x -= r[i] - temp - 1
			temp = r[i]
		i += 1
	temp += x
	print(temp)


for i in range(0, int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a = list(set(a))
	a.sort()
	z = 1
	p = 0
	q = 0
	f = 0
	while q != x:
		if p < len(a) and a[p] == z:
			p = p + 1
		else:
			q = q + 1
		z = z + 1
	if z not in a:
		print(z - 1)
	else:
		while z in a:
			z = z + 1
		print(z - 1)


def possible(arr, v, x):
	visited = set()
	for i in arr:
		if i <= v:
			visited.add(i)
	for i in range(1, v + 1):
		if i not in visited:
			x -= 1
	if x < 0:
		return False
	return True

def solve(arr, x):
	arr = list(arr)
	arr.sort()
	for v in range(300, 0, -1):
		if possible(arr, v, x):
			print(v)
			return

def main():
	t = int(input())
	for i in range(t):
		(n, x) = map(int, input().split())
		arr = set(map(int, input().split()))
		solve(arr, x)
main()


import sys
input = lambda : sys.stdin.readline().strip()
ipnut = input
for i in range(int(input())):
	(n, x) = map(int, ipnut().split())
	a = set(list(map(int, ipnut().split())))
	i = 0
	while x:
		i += 1
		if i not in a:
			x -= 1
	while i + 1 in a:
		i += 1
	print(i)


t = int(input())
while t:
	t -= 1
	li = list(map(int, input().split()))
	(n, x) = (li[0], li[1])
	nums = list(map(int, input().split()))
	for v in range(n + x, 0, -1):
		mp = {}
		for num in nums:
			if num <= v and num not in mp:
				mp[num] = 1
		if len(mp) == v - x:
			print(v)
			break


from sys import stdin
from collections import Counter
from math import sqrt, factorial, log10, log, floor, ceil
from itertools import permutations, combinations, combinations_with_replacement
input = stdin.readline

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

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

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

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

def inps():
	return str(input().strip())

def pr(n):
	return stdout.write(str(n) + '\n')
INF = float('inf')

def solve():
	(n, k) = mp()
	a = li()
	a.sort()
	a = set(a)
	(res, i) = (0, 1)
	while k > 0:
		if i not in a:
			res += 1
			k -= 1
		else:
			res += 1
		i += 1
	while res + 1 in a:
		res += 1
	print(res)
t = inp()
for i in range(t):
	solve()


for qw in range(int(input())):
	(n, x) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	arr = list(set(arr))
	arr.sort()
	done = [0] * 300
	for i in arr:
		done[i] = 1
	available = x
	start = 1
	while available > 0:
		if done[start] == 0:
			done[start] = 1
			available -= 1
		start += 1
	ans = 0
	for i in range(1, 300):
		if done[i] == 0:
			ans = i - 1
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split(' '))
	data = list(map(int, input().split(' ')))
	temp = {}
	for i in data:
		if i not in temp:
			temp[i] = 1
	now = 1
	result = 1
	while x > 0:
		while True:
			if now in temp:
				result = now
				now += 1
			else:
				break
		x -= 1
		result = now
		now += 1
	while True:
		if now in temp:
			result = now
			now += 1
		else:
			break
	print(result)


case = int(input())
for i in range(case):
	(end, rest) = map(int, input().split())
	place = set(map(int, input().split()))
	i = 1
	while rest != 0:
		if place.__contains__(i):
			i += 1
			continue
		else:
			rest -= 1
			i += 1
	while place.__contains__(i):
		i += 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	array = list(map(int, input().split()))
	ans = 1
	while True:
		if ans in array:
			ans += 1
		elif x > 0:
			ans += 1
			x -= 1
		else:
			ans -= 1
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	p = 0
	for i in range(1, 1000):
		if x:
			if i not in a:
				x -= 1
				p = i
		elif i not in a:
			p = i - 1
			break
	print(p)


def main():
	for _ in range(int(input())):
		(n, x) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		a.sort()
		l = [-1] * 300
		l[0] = 1
		for i in a:
			l[i] = 1
		i = 1
		while 1:
			if l[i] == 1:
				i += 1
			else:
				x -= 1
				l[i] = 1
				i += 1
			if x == 0:
				break
		print(l.index(-1) - 1)
main()


R = lambda : map(int, input().split())
t = int(input())

def solve(a, n, x):
	ans = [0] * 301
	for i in range(n):
		ans[a[i]] = 1
		cnt = 0
	cnt = 0
	for i in range(1, 300):
		if ans[i] == 0:
			cnt += 1
			if cnt == x + 1:
				return i - 1
for _ in range(t):
	(n, x) = R()
	a = list(R())
	print(solve(a, n, x))


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = set([int(x) for x in input().split()])
	for i in range(1, 1000):
		if i in a:
			continue
		if x == 0:
			print(i - 1)
			break
		x -= 1


import math as mt
dic = [chr(i) for i in range(97, 123)]
for _ in range(int(input())):
	(n, x) = [int(j) for j in input().split()]
	k = [int(j) for j in input().split()]
	k = sorted(set(k))
	j = 1
	while True:
		if j not in k:
			x = x - 1
		j = j + 1
		if x == 0:
			while True:
				if j not in k:
					print(j - 1)
					break
				else:
					j = j + 1
			break


def bin_search(arr, k, l, r):
	if l <= r:
		m = (l + r) // 2
		if arr[m] == k:
			return True
		elif arr[m] < k:
			return bin_search(arr, k, m + 1, r)
		else:
			return bin_search(arr, k, l, m - 1)
	return False

def ans(a, x, n):
	current = 1
	while True:
		if bin_search(a, current, 0, n - 1):
			current += 1
		else:
			if x == 0:
				print(current - 1)
				break
			x -= 1
			current += 1
for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	ans(a, x, n)


import sys
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	v = 0
	count = 1
	while x > 0:
		if count in l:
			v += 1
		else:
			v += 1
			x -= 1
		count += 1
	while v + 1 in l:
		v = v + 1
	print(v)


t = int(input())
while t > 0:
	a = []
	for i in range(201):
		a.append(0)
	(n, x) = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in b:
		a[i] = 1
	ans = 0
	i = 1
	while x > 0 and i <= 200:
		if a[i] == 0:
			a[i] = 1
			x -= 1
			ans = i
		i += 1
	while i <= 200:
		if a[i] == 1:
			ans = i
			i += 1
		else:
			break
	print(ans)
	t -= 1


t = int(input())
for i in range(0, t):
	(n, x) = [int(p) for p in input().split()]
	l = [int(r) for r in input().split()]
	j = 1
	while x != 0:
		if j not in l:
			x -= 1
		j += 1
	if x == 0:
		while True:
			if j not in l:
				break
			j += 1
	print(j - 1)


import sys
r = int(input())
t = -1

def input():
	global t
	t += 1
	return data[t]
data = sys.stdin.readlines()
for _ in range(r):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	count = x
	for i in range(1, n + x + 1):
		if i not in a:
			if count > 0:
				count -= 1
			else:
				i -= 1
				break
	print(i)


from sys import stdin
import math
a = int(stdin.readline())
for k in range(0, a):
	A = stdin.readline().split()
	N = int(A[0])
	X = int(A[1])
	D = stdin.readline().split()
	temp = 0
	while X >= 0:
		temp += 1
		if D.count(str(temp)) > 0:
			X += 0
		else:
			X -= 1
		if X < 0:
			temp -= 1
	print(temp)


t = int(input())
for k in range(t):
	(n, x) = [int(x) for x in input().split()]
	p = [int(i) for i in input().split()]
	i = 1
	c = 0
	while i > 0:
		if i in p:
			c = i
		elif x == 0:
			break
		else:
			x -= 1
			c += 1
		i += 1
	print(c)


import sys, bisect
from math import gcd
input = sys.stdin.readline

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

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

def insr():
	s = input().rstrip()
	return s[:len(s) - 1]

def invr():
	return map(int, input().rstrip().split())
t = inp()
for _ in range(t):
	(n, x) = invr()
	nums = inlt()
	ans = [0 for i in range(max(nums) + 1)]
	for i in nums:
		ans[i] = 1
	index = x
	r_ans = 0
	while index > 0:
		for i in range(1, len(ans)):
			if ans[i] == 0:
				ans[i] = 1
				r_ans = i
				break
		else:
			ans.append(1)
			r_ans = len(ans)
		index -= 1
	r_ans = len(ans)
	for i in range(1, len(ans)):
		if ans[i] == 0:
			r_ans = i
			break
	print(r_ans - 1)


def disp(a):
	for i in range(len(a)):
		print(a[i], end=' ')
	print()
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	a = list(a)
	a = sorted(a)
	length = len(a)
	v = 0
	num = 0
	k = 1
	while True:
		if num < length and a[num] == k:
			num += 1
			k += 1
			v += 1
		elif x > 0:
			k += 1
			x -= 1
			v += 1
		elif x <= 0:
			break
	print(v)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	al = list(map(int, input().split()))
	dl = [0] * (n + 1)
	for i in range(n):
		if al[i] <= n:
			if dl[al[i]] == 0:
				dl[al[i]] = 1
	alrcnt = dl.count(1)
	dl += [0] * x
	for i in range(n + x + 1):
		if i in al:
			dl[i] = 1
		if dl[i] == 0 and i != 0 and (x > 0):
			dl[i] = 1
			x -= 1
	dl = dl[1:]
	if 0 in dl:
		print(dl.index(0))
	else:
		print(dl.count(1))


T = int(input())
for t in range(T):
	(N, X) = map(int, input().split())
	a = map(int, input().split())
	a = set(a)
	for i in range(1, N + X + 1):
		if i not in a:
			X -= 1
			if X < 0:
				i -= 1
				break
	print(i)


import heapq
t = input()
t = int(t)
for case in range(t):
	a = input().split()
	n = int(a[0])
	x = int(a[1])
	a = input().split()
	lst = [int(i) for i in a]
	dct = {}
	for i in lst:
		dct[i] = True
	ans = 0
	for i in range(1, 500):
		try:
			cek = dct[i]
		except:
			cek = False
		if x == 0 and (not cek):
			break
		if not cek:
			dct[i] = True
			x -= 1
		ans = i
	print(ans)


t = int(input())
for _ in range(t):
	valid = [False] * 250
	(n, x) = map(int, input().split())
	pos = set(map(int, input().split()))
	for p in pos:
		valid[p - 1] = True
	for v in range(len(valid)):
		if valid[v] == False:
			valid[v] = True
			x -= 1
		if x == 0:
			break
	ans = 0
	for i in range(len(valid)):
		if valid[i] == False:
			ans = i
			break
	print(ans)


def solve():
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	a = sorted(a)
	last_place = 0
	i = 0
	while i < len(a):
		if a[i] > last_place + 1:
			if x == 0:
				break
			else:
				x -= 1
		else:
			i += 1
		last_place += 1
	last_place += x
	return last_place
t = int(input())
for i in range(t):
	print(solve())


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a = set(a)
	l = len(a)
	s = x + l
	u = set([i for i in range(1, s + 1)])
	while 1:
		a = u.intersection(a)
		if len(u.difference(a)) == x:
			z = len(u)
			break
		else:
			u.discard(len(u))
	print(z)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(set(map(int, input().split())))
	i = 1
	while x > 0:
		if i not in l:
			l.append(i)
			x -= 1
		i += 1
	l.sort()
	last = False
	for i in range(0, len(l) - 1):
		if l[i + 1] - l[i] != 1:
			last = False
			break
		else:
			last = True
	if last:
		print(l[i + 1])
	else:
		print(l[i])


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for _ in range(t):
	(n, x) = M()
	l = L()
	l = list(set(l))
	l.sort()
	v = 0
	i = 0
	while i < len(l):
		if l[i] == v + 1:
			v += 1
			i += 1
		else:
			x -= 1
			if x < 0:
				break
			v += 1
	if x != 0 and x > 0:
		v += x
	print(v)


T = int(input())
for t in range(1, T + 1):
	pass
	(n, x) = map(int, input().split())
	places = [int(x) for x in input().split()]
	currentPlace = 0
	inserted = 0
	while inserted < x or currentPlace + 1 in places:
		if currentPlace + 1 in places:
			currentPlace += 1
			continue
		places.append(currentPlace + 1)
		currentPlace += 1
		inserted += 1
	print(currentPlace)


input = __import__('sys').stdin.readline
print = __import__('sys').stdout.write
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	t = [False for _ in range(300)]
	for i in map(int, input().split()):
		t[i] = True
	idx = 1
	for i in range(x):
		while True:
			if not t[idx]:
				t[idx] = True
				break
			idx += 1
	for i in range(idx, 300):
		if not t[i]:
			print(f'{i - 1}\n')
			break


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	(*a,) = map(int, input().split())
	b = [0] * 201
	for i in a:
		b[i] |= 1
	ans = 0
	for i in b[1:]:
		if not i:
			x -= 1
		if x == -1:
			break
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = set(a)
	b = list(c)
	b.sort()
	l = len(b)
	flag = 0
	while l > 0:
		r = b[l - 1] - l
		if x < r:
			l -= 1
		elif x == r:
			print(b[l - 1])
			flag = 1
			break
		else:
			print(b[l - 1] + x - r)
			flag = 1
			break
	if flag == 0:
		print(x)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = [0] * 500
	a = list(map(int, input().split()))
	for y in a:
		arr[y - 1] = 1
	i = 0
	while True:
		if arr[i] == 0:
			if x > 0:
				x -= 1
			else:
				break
		i += 1
	print(i)


t = int(input())
for k in range(t):
	(n, x) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	here = [0] * 1000
	for i in a:
		here[i] = 1
	over = 0
	for i in range(1, 1000):
		if not here[i]:
			over += 1
			if over > x:
				break
	print(i - 1)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

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

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

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	(n, x) = mp()
	arr = lmp()
	tog = l1d(301, False)
	for i in arr:
		tog[i - 1] = True
	i = 0
	while x or tog[i]:
		if not tog[i]:
			x -= 1
		i += 1
	print(i)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = list(set(l))
	s.sort()
	for i in s:
		if i <= x + 1:
			x += 1
	print(x)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = set(arr)
	i = 1
	while x != 0:
		if i not in s:
			x -= 1
		i += 1
		if x == 0 and i not in s:
			i -= 1
		if x == 0:
			while i + 1 in arr:
				i += 1
	print(i)


t = int(input())
while t:
	l = [0] * 201
	(n, x) = map(int, input().split())
	ll = list(map(int, input().split()))
	for i in range(len(ll)):
		l[ll[i] - 1] += 1
	for i in range(x):
		l[l.index(0)] += 1
	for i in range(len(l)):
		if l[i] == 0:
			print(i)
			break
	t -= 1


from math import *
T = int(input())
for _ in range(T):
	(N, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	Dict = {}
	Arr = []
	for i in arr:
		Dict[i] = 1
	for i in range(1, 201):
		if x <= 0:
			if i in Dict:
				Arr.append(i)
			else:
				break
		elif i not in Dict:
			x -= 1
		Arr.append(i)
	print(Arr[len(Arr) - 1])


l = []
t = int(input())
while t:
	k = 0
	(n, x) = [int(x) for x in input().split()]
	k1 = 0
	a = input()
	l = list(map(int, a.split(' ')))
	while x != 0:
		k = k + 1
		if k not in l:
			x = x - 1
	k = k + 1
	while True:
		if k + k1 not in l:
			break
		k1 = k1 + 1
	print(k + k1 - 1)
	l.clear()
	t = t - 1


from collections import defaultdict
T = int(input())
for t in range(1, T + 1):
	(n, x) = (int(i) for i in input().split(' '))
	nums_d = defaultdict(int)
	nums = [int(i) for i in input().split()]
	for i in nums:
		nums_d[i] = 1
	missed = 0
	for i in range(1, n + x + 1):
		if nums_d[i] == 0:
			missed += 1
		if missed > x:
			print(str(i - 1))
			break
	else:
		print(str(n + x))


from collections import defaultdict as dc
from heapq import *
import math
import bisect
import sys
from collections import deque as dq
mod = 10 ** 12

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

def line():
	p = list(map(int, input().split()))
	return p

def digit(n):
	s = str(n)
	p = 0
	for i in s:
		p += int(i) ** 2
	return p

def check(a, b):
	c = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			c += 1
			if c > 1:
				return 0
	return 1
for _ in range(inp()):
	(n, k) = line()
	a = line()
	a = list(set(a))
	z = 1
	a.sort()
	n = len(a)
	ans = 0
	for i in range(n):
		p = a[i]
		need = p - z
		if need <= k:
			k = k - need
			z = p + 1
			ans = max(ans, p)
		else:
			break
	if k > 0:
		ans = ans + k
	print(ans)


for q in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	v = [0] * 220
	for i in a:
		v[i] = 1
	for i in range(1, 220):
		if v[i] == 0:
			if x > 0:
				x -= 1
				v[i] = 1
	for i in range(1, 220):
		if v[i] == 0:
			print(i - 1)
			break


import sys
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		d[i] = 1
	p = 0
	for i in range(1, max(a) + x + 1):
		if x > 0 and i not in d:
			x = x - 1
			p = max(i, p)
		elif i in d:
			p = max(i, p)
		else:
			break
	print(p)


tes = int(input())
for i in range(0, tes):
	(n, x) = input().split()
	x = int(x)
	n = int(n)
	inp = list(map(int, input().split()))
	curr = 1
	while x > -1:
		if curr not in inp:
			x = x - 1
		ans = curr
		curr = curr + 1
	print(ans - 1)


n = int(input())
k = []
for i in range(n):
	(y, x) = list(map(int, input().rstrip().split()))
	a = list(map(int, input().rstrip().split()))
	l = []
	for f in a:
		if f not in l:
			l.append(f)
	l.sort()
	s = len(l)
	for j in range(s):
		if l[j] <= x:
			x = x + 1
		elif l[j] == x + 1:
			x = x + 1
		else:
			break
	k.append(x)
for z in range(n):
	print(k[z])


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = sorted([int(x) for x in input().split()])
	i = 0
	while x != 0:
		i += 1
		if i not in a:
			x -= 1
	while i + 1 in a:
		i += 1
	print(i)


def main():
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	st = set()
	for i in lst:
		st.add(i)
	have_to_be = len(st) + x
	i = 0
	while x > -1:
		i += 1
		if i in st:
			pass
		else:
			x -= 1
	print(i - 1)
t = int(input())
for i in range(t):
	main()


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	h = [0] * 500
	for val in arr:
		h[val] += 1
	ans = None
	for i in range(1, len(h)):
		val = h[i]
		if val == 0:
			x -= 1
		else:
			continue
		if x < 0:
			ans = i - 1
			break
	print(ans)


def solve(l):
	for j in range(l):
		f = 0
		(n, x) = map(int, input().split())
		m = input().split()
		for i in range(0, len(m)):
			m[i] = int(m[i])
		m.sort(reverse=False)
		while x > -1:
			f = f + 1
			if f not in m:
				x = x - 1
		print(f - 1)
solve(int(input()))


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	count = 0
	for k in range(1, max(a) + 1):
		if x == 0 and k not in a:
			break
		if k not in a:
			count = k
			x -= 1
		else:
			count = k
	count += x
	print(count)


for _ in range(int(input())):
	a = input().split(' ')
	n = int(a[0])
	x = int(a[1])
	a = input().split(' ')
	for i in range(n):
		a[i] = int(a[i])
	count = 1
	while True:
		if count in a:
			count = count + 1
		elif x > 0:
			x = x - 1
			count = count + 1
		else:
			break
	print(count - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = set(map(int, input().split()))
	i = 0
	while x >= 0:
		i += 1
		if i in a:
			continue
		x -= 1
	print(i - 1)


def tsk():
	(n, x) = map(int, input().split())
	r = list(map(int, input().split()))
	r.sort()
	msk = [False] * max(r)
	for v in r:
		msk[v - 1] = True
	i = 0
	for i in range(max(r)):
		if not msk[i - 1]:
			x -= 1
		if x == -1:
			break
	if x == -1:
		print(i - 1)
	else:
		print(max(r) + x)
t = int(input())
for _ in range(t):
	tsk()


from collections import defaultdict
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	ans = 0
	for i in range(1, 201):
		if i in d:
			ans += 1
		else:
			if x == 0:
				break
			x -= 1
			ans += 1
	print(ans)


I = input
for i in range(int(I())):
	(n, m) = map(int, I().split())
	l = sorted(list(set(map(int, I().split()))))
	for i in l:
		if i <= m + 1:
			m += 1
	print(m)


total = set(range(1, 210))
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = set(map(int, input().split()))
	diff = sorted(list(total.difference(arr)))
	print(diff[k] - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	v = 0
	while x != 0:
		v += 1
		if v not in a:
			x -= 1
	while 1:
		if v + 1 in a:
			v += 1
		else:
			break
	print(v)


from sys import stdin, stdout
for i in range(int(stdin.readline())):
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	b = list(set(b))
	j = 1
	v = 0
	while a[1] > 0 or j in b:
		if j in b:
			v += 1
		else:
			a[1] -= 1
			v += 1
		j += 1
	print(v)


a = int(input())
for _ in range(a):
	(n, x) = map(int, input().split())
	k = list(map(int, input().split()))
	m = [0 for i in range(max(k) + x + 1)]
	for i in range(len(k)):
		if m[k[i] - 1] == 0:
			m[k[i] - 1] += 1
	i = 0
	while 1:
		if x == 0 and m[i] == 0:
			break
		if m[i] == 0:
			x = x - 1
		i = i + 1
	print(i)


import sys

def get_single_int():
	return int(sys.stdin.readline().strip())

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

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
for i in range(get_single_int()):
	(n, x) = get_ints()
	ar = sorted(get_list())
	i = 1
	while i in ar or x > 0:
		if i not in ar:
			x -= 1
		i += 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l = list(set(l))
	l = sorted(l)
	out = []
	for i in range(n + x):
		if i + 1 in l:
			out.append(i + 1)
		elif x > 0:
			out.append(i + 1)
			x -= 1
		else:
			break
	print(out[-1])


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	check = [False] * (n + 105)
	for idx in range(n):
		check[a[idx]] = True
	idx = 1
	while x >= 0:
		if check[idx] == False:
			x -= 1
		idx += 1
	print(idx - 2)


t = int(input())
al = []
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [0 for i in range(100)]
	ans = 0
	for j in range(n):
		l[a[j] - 1] = 1
	for j in range(100):
		if l[j] == 0:
			if x > 0:
				x -= 1
				ans += 1
			else:
				break
		else:
			ans += 1
	ans += x
	al.append(ans)
for i in al:
	print(i)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	(n, x) = getVars()
	a = getList()
	a.sort()
	for i in range(n):
		if (i == 0 or a[i] > a[i - 1]) and a[i] <= x + 1:
			x += 1
	print(x)


cases = int(input())
for case in range(cases):
	values = input().split()
	(done, extra) = (int(values[0]), int(values[1]))
	num_list = list(map(lambda x: int(x), input().split()))
	num_list.sort()
	filtered = [num_list[0]]
	for index in range(1, len(num_list)):
		if num_list[index] != num_list[index - 1]:
			filtered.append(num_list[index])
	for item in filtered:
		if item <= extra + 1:
			extra += 1
	print(extra)


t = int(input())
while t:
	(n, x) = [int(a) for a in input().split()]
	l = [int(b) for b in input().split()]
	v = 0
	i = 1
	while True:
		if not i in l:
			l.append(i)
			v += 1
			if v == x:
				break
		i += 1
	i = 0
	l = set(l)
	m = max(l) + 1
	for j in range(1, m):
		if j in l:
			i += 1
		else:
			break
	print(i)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = [0] * 202
	for i in l:
		d[i - 1] = 1
	an = 0
	for i in range(201):
		if d[i] == 0:
			k -= 1
			d[i] = 1
		if k == 0:
			an = i
			while d[an] == 1:
				an += 1
			break
	print(an)


T = int(input())
for _ in range(T):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	visit = set()
	for i in range(n):
		visit.add(a[i])
	ans = 0
	max_rank = max(max(a), n + x)
	for i in range(1, max_rank + 1):
		if i not in visit:
			x -= 1
			visit.add(i)
		if x == 0:
			break
	for i in range(1, max_rank + 1):
		if i in visit:
			ans = i
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	achieved = [False] * 201
	for i in range(n):
		achieved[a[i]] = True
	for i in range(n + x, 0, -1):
		v = 0
		for j in range(1, i + 1):
			if not achieved[j]:
				v += 1
		if v <= x:
			print(i)
			break


def solve(x, a):
	places = list(a)
	for i in range(x):
		num = 1
		while num in places:
			num += 1
		places.append(num)
	places.sort()
	for j in range(1, len(places)):
		if places[j] > places[j - 1] + 1:
			return j
	return len(places)
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	a = set(map(int, input().split(' ')))
	y = solve(x, a)
	print(y)


from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

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

def si():
	return str(input())

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

def li():
	return list(mi())

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

def fsi():
	return str(stdin.readline())

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

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

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

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1
for _ in range(ii()):
	(n, x) = mi()
	l = li()
	l = list(set(l))
	l = sorted(l)
	out = []
	for i in range(n + x):
		if i + 1 in l:
			out.append(i + 1)
		elif x > 0:
			out.append(i + 1)
			x -= 1
		else:
			break
	print(out[-1])


y = int(input())
for i in range(y):
	al = input().split()
	m = list(map(int, al))
	n = m[0]
	x = m[1]
	al = input().split()
	m = list(map(int, al))
	mas = n + x + 4
	li = [1] * mas
	for j in m:
		if j < mas:
			li[j] = 0
	j = 0
	while x > 0:
		j += 1
		if li[j] == 1:
			li[j] = 0
			x -= 1
	for k in range(j, mas):
		if li[k] == 1:
			break
	print(k - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	for j in range(1, n + x + 2):
		if j not in l and x > 0:
			x -= 1
		elif j not in l and x <= 0:
			print(j - 1)
			break


from collections import defaultdict
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	d = defaultdict()
	a = list(map(int, input().split()))
	for i in a:
		d[i] = 1
	k = 1
	while True:
		if k not in d:
			if x == 0:
				break
			else:
				x -= 1
		k += 1
	print(k - 1)


t = int(input())
for k in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = list(set(arr))
	arr.sort()
	test = [0 for i in range(201)]
	for i in range(len(arr)):
		test[arr[i] - 1] = 1
	i = 0
	while x > 0 and i < 201:
		if test[i] == 0:
			test[i] = 1
			x -= 1
		i += 1
	for i in range(201):
		if test[i] == 0:
			print(i)
			break


from typing import List
import bisect

def get_int():
	return int(input())

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

def solve(n: int, a: List[int], x: int):
	a.sort()
	a_set = set(a)
	elem = 0
	while x > 0:
		elem += 1
		if elem not in a_set:
			j = bisect.bisect(a, elem)
			a.insert(j, elem)
			a_set.add(elem)
			x -= 1
	while elem + 1 in a_set:
		elem += 1
	return elem
t = get_int()
for _ in range(t):
	(n, x) = get_ints()
	a = get_ints()
	sol = solve(n, a, x)
	print(sol)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	A = list(set(list(map(int, input().split()))))
	ans = 0
	while True:
		if len(A) == 0:
			ans += x
			break
		m = min(A)
		A.remove(m)
		if x < m - 1 - ans:
			ans += x
			break
		else:
			x -= m - 1 - ans
			ans = m
	print(ans)


from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
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')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	for _ in range(N()):
		(n, x) = RL()
		arr = list(RL())
		rec = set(arr)
		res = 1
		while x > 0 or res in rec:
			if res not in rec:
				x -= 1
			res += 1
		print(res - 1)
main()


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(set(a))
	a.sort()
	pat = 1
	poi = 0
	for i in range(m):
		while poi < len(a) and pat == a[poi]:
			pat += 1
			poi += 1
		pat += 1
	tag = 0
	while poi < len(a) and pat == a[poi]:
		tag = 1
		pat += 1
		poi += 1
	print(pat - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [0] * max(a)
	for i in range(n):
		l[a[i] - 1] += 1
	res = 0
	for i in range(len(l)):
		if l[i] == 0:
			x = x - 1
			if x < 0:
				break
		res = i + 1
	if x > 0:
		res = res + x
	print(res)


t = int(input())
for _ in range(t):
	(n, x1) = map(int, input().split())
	a = [int(s) for s in input().split()]
	x = [0] * 1000
	a = list(set(a))
	a.sort()
	for i in range(len(a)):
		x[a[i]] = 1
	f = 0
	v1 = x1
	for i in range(1, 1000):
		if x[i] == 0 and v1:
			x[i] = 1
			v1 -= 1
	for i in range(1, 1000):
		if x[i] == 0:
			print(i - 1)
			break


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = sorted(set(list(map(int, input().split()))))
	num = 1
	ind = 0
	check_1 = 0
	while check_1 == 0:
		if ind < len(A) and A[ind] == num:
			num += 1
			ind += 1
		elif k == 0:
			check_1 = 1
		else:
			k -= 1
			num += 1
	print(num - 1)


def ext(a):
	last = 0
	for (i, x) in enumerate(a):
		if x != last + 1:
			a.insert(i, last + 1)
			return
		last = x
	a.append(a[-1] + 1)

def or_l(a):
	last = 0
	count = 0
	for x in a:
		if x == last + 1:
			count += 1
		else:
			break
		last = x
	return count
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(set(a))
	for j in range(x):
		ext(a)
	print(or_l(a))


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	used = [0] * 201
	for j in range(n):
		used[a[j] - 1] = 1
	lim = x
	for j in range(n + x + 1):
		if used[j] == 0 and lim >= 1:
			lim -= 1
		elif used[j] == 0:
			print(j)
			break


R = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, x) = R()
	a = set(R())
	cnt = 0
	while 1:
		cnt += 1
		if cnt not in a:
			if x == 0:
				print(cnt - 1)
				break
			x -= 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * (n + x + 1)
	for i in a:
		if i <= n + x and b[i] != 1:
			b[i] = 1
	t = 1
	for i in range(1, n + x + 1):
		if b[i] == 0 and x > 0:
			x -= 1
		elif b[i] == 0:
			break
		t += 1
	print(t - 1)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	temp = sorted(set(l))
	i = 0
	while x != 0:
		if i + 1 not in temp:
			x -= 1
			temp.insert(i, i + 1)
		i += 1
	c = 1
	for i in temp:
		if i == c:
			c += 1
		else:
			break
	print(c - 1)


for q in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	d = set([int(i) for i in input().split()])
	r = 0
	while x:
		if r + 1 in d:
			pass
		else:
			x -= 1
		r += 1
	while r + 1 in d:
		r += 1
	print(r)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	a = []
	for i in range(101):
		a.append(-1)
	for i in range(n):
		temp = l[i]
		temp = temp - 1
		a[temp] = 1
	i = 0
	while x >= 0 and i <= 100:
		if a[i] == -1:
			x = x - 1
			if x == -1:
				break
			else:
				i += 1
		else:
			i += 1
	if x != -1:
		i = i + x
	print(i)


from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect

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

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

def LS():
	return [list(x) for x in sys.stdin.readline().split()]

def S():
	res = list(sys.stdin.readline())
	if res[-1] == '\n':
		return res[:-1]
	return res

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
	t = I()
	for _ in range(t):
		(n, x) = LI()
		a = LI()
		d = defaultdict(lambda : 0)
		for i in a:
			d[i] = 1
		i = 0
		while x or d[i]:
			i += 1
			if d[i]:
				continue
			x -= 1
		i += 1
		while d[i]:
			i += 1
		print(i - 1)
	return
solve()


from collections import Counter
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	d = Counter(l)
	count = 0
	for i in range(1, 300):
		if i in d.keys() and b >= 0:
			count += 1
		elif b >= 0:
			b -= 1
			if b < 0:
				break
			count += 1
	print(count)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list((False for i in range(max(l) + y)))
	(count, z) = (0, 0)
	for j in range(x):
		p[l[j] - 1] = True
	for q in p:
		if q != False:
			count += 1
		elif q == False and z < y:
			count += 1
			z += 1
		else:
			break
	print(count)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(dict.fromkeys(a))
	a.sort()
	count = 0
	for i in range(0, max(a) + 1):
		if a.count(i + 1) > 0:
			count += 1
		elif x != 0:
			x -= 1
			count += 1
		else:
			break
	print(count + x)


from sys import stdin, stdout
from math import *
input = stdin.readline
for __ in range(int(input())):
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort()
	a = [0] * 500
	for i in ar:
		a[i] = 1
	for i in range(1, len(a)):
		if a[i] == 0:
			if m == 0 and a[i] == 0:
				ans = i - 1
				break
			else:
				m -= 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = set([int(s) for s in input().split()])
	a = sorted(list(a))
	p = [0] * (n + x)
	x1 = x
	for i in range(n + x):
		if len(a) > 0 and a[0] - 1 == i:
			a.pop(0)
			p[i] = 1
		elif x1 > 0:
			x1 -= 1
			p[i] = 1
		else:
			print(i)
			break
	else:
		print(n + x)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	m = min(a)
	mm = max(a) + x + 1
	c = 0
	for i in range(1, mm):
		c += 1
		if i not in a:
			x = x - 1
		if x == -1:
			c -= 1
			break
	print(c)


def I():
	return list(map(int, input().split()))
t = int(input())
while t > 0:
	(n, x) = I()
	a = [0] * 201
	l = I()
	for i in range(n):
		a[l[i] - 1] = 1
	for i in range(201):
		if a[i] == 0 and x > 0:
			a[i] = 1
			x -= 1
		if x == 0:
			break
	ans = -1
	for i in range(201):
		if a[i] == 0:
			ans = i
			break
	print(ans)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.append(0)
	l = list(set(l))
	l.sort()
	ans = 0
	i = 0
	for i in range(1, len(l)):
		temp = l[i] - l[i - 1] - 1
		if k < temp:
			ans += k
			if i != 1:
				ans += 1
			k = 0
			break
		else:
			k -= temp
			if i != 1:
				ans += 1
			ans += temp
	if ans + 1 == l[i]:
		ans += 1
	ans += k
	print(ans)


def solve(a, x):
	for i in range(1, max(a) + x + 5):
		if x <= 0 and i not in a:
			return i
		if x > 0 and i not in a:
			x -= 1
t = int(input())
while t:
	t -= 1
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	v = solve(a, x)
	print(v - 1)


test = input()
for t in range(int(test)):
	nx = input().split()
	n = int(nx[0])
	x = int(nx[1])
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	achievable = x
	places = {}
	count = 0
	stillwork = True
	while stillwork:
		stillwork = False
		for i in range(n):
			if a[i] <= achievable + 1 and a[i] not in places:
				count += 1
				places[a[i]] = 1
				achievable += 1
				stillwork = True
	print(achievable)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [False] * (max(a) + 1)
	for i in range(len(a)):
		b[a[i]] = True
	missing = 0
	ans = 0
	i = 1
	while i < len(b):
		if b[i] == False:
			missing += 1
		if missing <= x:
			ans = max(ans, i)
		i += 1
	if missing < x:
		ans = len(b) - 1 + x - missing
	print(ans)


T = int(input())
while T:
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A = list(set(A))
	A.sort()
	C = [0 for i in range(1000)]
	C[0] = 1
	for i in A:
		C[i] = 1
	i = 0
	while x > 0:
		if C[i] == 0:
			C[i] = 1
			x -= 1
		i += 1
	for i in range(1000):
		if C[i] == 0:
			j = i
			break
	print(j - 1)
	T = T - 1


T = int(input())
n = [0] * T
ns = [0] * T
for t in range(T):
	(d, n[t]) = [int(i) for i in input().split(' ')]
	ns[t] = [int(i) for i in input().split(' ')]
for t in range(T):
	ns[t].sort()
	for i in range(1, len(ns[t]) + n[t] + 5):
		if i not in ns[t]:
			n[t] -= 1
		if n[t] == 0:
			I = i
			break
	for i in range(I + 1, max(ns[t]) + 2):
		if i not in ns[t]:
			print(i - 1)
			I = -1
			break
	if I != -1:
		print(I)


t = int(input())
output = []
for i in range(t):
	(n, x) = map(int, input().split())
	places = sorted(list(set(map(int, input().split()))))
	v = 0
	if x < places[0] - 1:
		v += x
	elif len(places) == 1:
		v += x + 1
	else:
		v += x
		for j in range(len(places)):
			if places[j] - 1 <= v:
				v += 1
	output.append(v)
for i in output:
	print(i)


T = int(input())
for t in range(T):
	(n, x) = tuple(map(int, input().split()))
	a = set(list(map(int, input().split())))
	i = 1
	while x > 0 or i in a:
		if i not in a:
			x -= 1
		i += 1
	print(i - 1)


for i in range(int(input())):
	(n, v) = map(int, input().split())
	l = list(map(int, input().split()))
	x = dict()
	for i in l:
		if i not in x:
			x[i] = 1
		else:
			x[i] += 1
	i = 1
	max = 0
	while v > 0:
		if i in x:
			i += 1
		else:
			v -= 1
			max = i
			i += 1
	while max + 1 in x:
		max += 1
	print(max)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

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

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
for _ in range(inn()):
	(n, x) = value()
	visit = [False] * 500
	a = arr()
	for i in a:
		visit[i] = True
	i = 1
	while x > 0:
		if visit[i] == False:
			visit[i] = True
			x -= 1
		i += 1
	for i in range(1, 500):
		if visit[i] == False:
			print(i - 1)
			break


from collections import Counter
for afbsi in range(int(input())):
	(n, x) = map(int, input().split())
	la = list(map(int, input().split()))
	l = list(Counter(la))
	l.sort()
	cou = 1
	i = 0
	ans = 0
	go = True
	while go:
		if i < len(l) and cou == l[i]:
			cou += 1
			i += 1
			ans += 1
		elif x > 0:
			cou += 1
			x -= 1
			ans += 1
		else:
			go = False
	print(ans)


import math

class Solution:

	def GetHighestConsecRanking(self, n, x, arr):
		setList = list(set(arr))
		borrow = x
		maxI = 0
		for i in range(1, max(setList) + 1):
			if i in setList:
				maxI = i
				continue
			elif borrow > 0:
				borrow -= 1
				maxI = i
				continue
			else:
				break
		if borrow > 0:
			maxI += borrow
		return maxI
instance = Solution()
t = int(input())
inputs = []
for i in range(0, t):
	(n, x) = [int(s) for s in input().split(' ')]
	arr = [int(s) for s in input().split(' ')]
	inputs.append([[n, x], arr])
outputs = []
for i in range(0, len(inputs)):
	outputs.append(instance.GetHighestConsecRanking(inputs[i][0][0], inputs[i][0][1], inputs[i][1]))
for i in range(0, len(outputs)):
	print('{}'.format(outputs[i]))


T = int(input())
for _ in range(T):
	(m, n) = map(int, input().split())
	pool = set(list(map(int, input().split())))
	n_num = 0
	while n >= 0:
		n_num += 1
		if n_num not in pool:
			n -= 1
	print(n_num - 1)


from sys import stdin, stdout

def read():
	x0 = stdin.readline().rstrip()
	return x0

def __main__():
	t = int(read())
	for t0 in range(t):
		(n, x) = map(int, read().split())
		ax = [int(i) for i in read().split()]
		ay = set(ax)
		k_max = n + x
		az = set((j + 1 for j in range(k_max)))
		delta = az - ay
		ds = list(delta)
		ds.sort()
		for j in range(x):
			elem = ds[j]
			ay.add(elem)
		ar = [d for d in ay if d <= k_max]
		ar.sort()
		ind = 0
		res = 0
		for k in range(len(ar)):
			elem = ar[k]
			ind += 1
			if elem == ind:
				res += 1
		nx = str(res) + '\n'
		stdout.write(nx)
__main__()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l1 = list(set(l1))
	l2 = [0] * 300
	for i in range(len(l1)):
		l2[l1[i]] = 1
	for i in range(1, 300):
		if l2[i] != 1:
			if x > 0:
				x = x - 1
			else:
				c = i
				break
	print(c - 1)


def ans(a, n, x):
	a.sort()
	b = []
	for i in a:
		if i not in b:
			b.append(i)
	count = x
	v = 0
	val = 1
	while count > 0 and v < len(b):
		if b[v] == val:
			v += 1
			val += 1
		else:
			count -= 1
			val += 1
	if count > 0:
		val += count
	while v < len(b):
		if b[v] == val:
			v += 1
			val += 1
		else:
			break
	return val - 1
n = int(input())
for i in range(n):
	t = input()
	t = t.split()
	n = int(t[0])
	x = int(t[1])
	c = input()
	c = c.split()
	a = []
	for j in c:
		a.append(int(j))
	print(ans(a, n, x))


t = int(input())
for _ in range(t):
	count = 0
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	s = list(set(c))
	s.sort()
	for i in range(1, 100000000000000):
		if i not in s:
			b = b - 1
			if b < 0:
				print(i - 1)
				break
		else:
			continue


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
sys.setrecursionlimit(10 ** 2)

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k))))
from collections import deque, defaultdict
import heapq

def solution(a, n, x):
	a = sorted(set(a))
	total = 0
	a = [0] + a
	for i in range(1, len(a)):
		c = a[i]
		if a[i] - a[i - 1] - 1 > x:
			return a[i - 1] + x
		else:
			x -= a[i] - a[i - 1] - 1
	return a[len(a) - 1] + x

def main():
	T = ri()
	for i in range(T):
		(n, x) = ria()
		a = ria()
		x = solution(a, n, x)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	ar = [int(x) for x in input().split()]
	ar = [0] + sorted(list(set(ar)))
	i = 1
	while i < len(ar):
		if ar[i] > ar[i - 1] + 1:
			x -= ar[i] - ar[i - 1] - 1
		if x < 0:
			print(ar[i - 1] + x + (ar[i] - ar[i - 1] - 1))
			i = -1
			break
		i += 1
	if i > -1:
		print(ar[-1] + x)


def removeDuplicates(arr, n):
	if n == 0 or n == 1:
		return n
	j = 0
	for i in range(0, n - 1):
		if arr[i] != arr[i + 1]:
			arr[j] = arr[i]
			j += 1
	arr[j] = arr[n - 1]
	j += 1
	return j
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	n = removeDuplicates(a, n)
	m = max(a) + x + 2
	mx = -1
	for i in range(1, m + 1):
		c = 0
		for j in range(n):
			if a[j] <= i:
				c = c + 1
		if c + x == i:
			mx = max(mx, i)
	print(mx)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	seen = set(a)
	for i in range(1, 200):
		if i not in seen:
			if x > 0:
				x -= 1
			else:
				print(i - 1)
				break
	else:
		print(200)


t = int(input())
for q in range(t):
	nx = list(map(int, input().split(' ')))
	(n, x) = (nx[0], nx[1])
	a = list(map(int, input().split(' ')))
	if 1 not in a:
		a.append(1)
		x -= 1
	a = list(set(a))
	a.sort()
	cc = True
	for q in range(1, len(a)):
		diff = a[q] - a[q - 1]
		if x >= diff - 1:
			x -= diff - 1
		else:
			print(a[q - 1] + x)
			cc = False
			break
	if cc:
		print(a[-1] + x)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	ptr = 1
	for i in l:
		if i == ptr:
			ptr += 1
		elif i > ptr:
			if x == 0:
				break
			k = i - ptr
			if k <= x:
				x -= k
				ptr += k + 1
			else:
				break
	ptr += x
	x = 0
	print(ptr - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	tmp = [0] * 300
	l = list(map(int, input().split()))
	for i in l:
		tmp[i - 1] = 1
	for i in range(300):
		if tmp[i] == 0:
			x -= 1
			if x < 0:
				print(i)
				break


for i in range(int(input())):
	(n, x) = (int(j) for j in input().split())
	a = [int(j) for j in input().split()]
	b = [0 for j in range(1000)]
	for j in range(n):
		b[a[j] - 1] = 1
	ans = 0
	for j in range(1000):
		if b[j] == 1:
			continue
		elif x > 0:
			b[j] = 1
			x -= 1
		else:
			ans = j
			break
	print(ans)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

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

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	(n, x) = mapi()
	a = list(mapi())
	ls = [0] * 500
	for i in a:
		ls[i] = 1
	cnt = 1
	while x > 0:
		while ls[cnt]:
			cnt += 1
		ls[cnt] = 1
		x -= 1
	while ls[cnt]:
		cnt += 1
	print(cnt - 1)


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	arr = tuple([int(i) for i in input().split()])
	i = 1
	while x >= 0:
		if i not in arr:
			x -= 1
		if x != -1:
			i += 1
	print(i - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = [int(y) for y in input().split()]
	hp = [0] * 210
	hp[0] = 1
	for j in arr:
		hp[j] = 1
	gs = 0
	cs = 0
	plug = 0
	for j in range(1, len(hp)):
		if hp[j] == 0 and plug < x:
			hp[j] = 1
			plug += 1
		elif hp[j] == 1:
			continue
		else:
			break
	st = ''.join([str(u) for u in hp]).replace('0', ' ').strip().replace(' ', '0')
	ind = -1
	for c in range(len(st)):
		if st[c] == '0':
			ind = c
			break
	if ind != -1:
		st = st[:ind]
	st = st[1:]
	print(len(st))


get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))

def main():
	for _ in range(get_int()):
		(n, x) = get_list()
		a = sorted(get_list())
		used = [0] * 205
		for i in a:
			used[i] = 1
		for i in range(1, 205):
			if used[i] == 0:
				used[i] = 1
				x -= 1
				if x == 0:
					for j in range(i + 1, 205):
						if used[j] == 0:
							print(j - 1)
							break
					break
main()


import sys
num = int(sys.stdin.readline().strip())
k = 0
while k < num:
	line1 = sys.stdin.readline().strip()
	line2 = sys.stdin.readline().strip()
	n_x = line1.split()
	n = int(n_x[0])
	x = int(n_x[1])
	a = line2.split()
	for i in range(len(a)):
		a[i] = int(a[i])
	v = 1
	while x != 0:
		if v in a:
			v += 1
			continue
		else:
			x -= 1
			if x == 0:
				break
		v += 1
	k += 1
	while True:
		if v + 1 in a:
			v = v + 1
		else:
			break
	print(v)


def f():
	t = int(input())
	for i in range(t):
		temp = input()
		temp = temp.split(' ')
		n = int(temp[0])
		x = int(temp[1])
		temp1 = input()
		temp1 = temp1.split(' ')
		temp1 = map(int, temp1)
		temp1 = list(temp1)
		total = len(temp1) + x
		res = []
		for i in range(1, total + 1):
			if x == 0 and i not in temp1:
				break
			if i in temp1:
				res.append(i)
			else:
				x = x - 1
				res.append(i)
		print(len(res))
f()


def f():
	(m, n) = input().split()
	(m, n) = (int(m), int(n))
	ls = sorted([int(x) for x in input().split()])
	res = 0
	i = 0
	while n >= 0 and i < m:
		if ls[i] > res + 1:
			if ls[i] - res - 1 > n:
				print(res + n)
				return
			else:
				n = n - (ls[i] - res - 1)
				res = ls[i]
		else:
			res = ls[i]
		i += 1
	res = res + n if n > 0 else res
	print(res)
num_inp = int(input())
for _ in range(num_inp):
	f()


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	pos = [0] * 105
	for i in range(n):
		pos[a[i]] = 1
	cnt = 0
	for i in range(1, len(pos)):
		if pos[i] == 0:
			x -= 1
		if x < 0:
			break
		cnt += 1
	if x >= 0:
		cnt += x
	print(cnt)


t = int(input())
for f in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	s = 0
	i = 0
	while x > -1:
		if i < n:
			if a[i] == s + 1:
				s += 1
				i += 1
			elif a[i] > s:
				x -= 1
				s += 1
			else:
				i += 1
		else:
			x -= 1
			s += 1
	print(s - 1)


t = int(input())
for k in range(t):
	(n, x) = [int(el) for el in input().split()]
	a = [int(el) for el in input().split()]
	places = [False for i in range(101)]
	for pos in a:
		places[pos] = True
	ans = 0
	for i in range(1, 101):
		if places[i]:
			ans += 1
			continue
		if x:
			ans += 1
			x -= 1
			continue
		break
	print(ans + x)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	y = input().split()
	ls = []
	for i in y:
		ls.append(int(i))
	num = 1
	count = 0
	while count <= x:
		if num in ls:
			pass
		elif count < x:
			count += 1
		else:
			break
		num += 1
	print(num - 1)
	t -= 1


t = int(input())
ans = []
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(set(map(int, input().split())))
	a.sort()
	v = x
	for e in a:
		if v >= e or e == v + 1:
			v += 1
	ans.append(v)
for a in ans:
	print(a)


from sys import exit

def i():
	return input()

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

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

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

def print_array(a):
	print(' '.join(map(str, a)))
t = ii()
for _ in range(t):
	(n, x) = iis()
	a = liis()
	a = set(a)
	numbers = [i for i in range(1, 300)]
	for i in numbers:
		if x == 0 and i not in a:
			break
		current = i
		if i not in a:
			x -= 1
	print(current)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	flag = 0
	for j in range(x + n, 1, -1):
		r = 0
		for k in range(1, j + 1):
			if k not in a:
				r += 1
		if r <= x:
			flag = 1
			print(j)
			break
	if flag == 0:
		print(x)


t = int(input())
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	a = list(map(int, input().split()))
	ctr1 = 1
	ctr = 0
	for i in range(1, n + x + 1):
		if i not in a:
			a.append(i)
			ctr += 1
		if ctr == x:
			break
	while True:
		if ctr1 in a:
			ctr1 += 1
		else:
			print(ctr1 - 1)
			break


t = int(input())

def solve():
	(n, x) = map(int, input().split())
	cnt = [False for i in range(303)]
	a = list(map(int, input().split()))
	for i in a:
		cnt[i - 1] = True
	ans = 0
	for (n, i) in enumerate(cnt):
		if not i:
			ans += 1
			if ans > x:
				ans = n
				break
	print(ans)
for _ in range(t):
	solve()


t = int(input())
result = []
for ind in range(0, t):
	inps = input().split()
	n = int(inps[0])
	x = int(inps[1])
	a = list(map(int, input().strip().split()))[:n]
	a.sort()
	if a[-1] == 1:
		result.append(x + 1)
	else:
		no_dup = []
		missing = []
		for i in a:
			if i not in no_dup:
				no_dup.append(i)
		for i in range(1, max(no_dup) + x + 1):
			if i not in no_dup:
				missing.append(i)
		add = missing[:x]
		temp_full = no_dup + add
		final = []
		for k in range(1, int(max(temp_full) + 1)):
			if k in temp_full:
				final.append(k)
			else:
				break
			final.sort()
			dhee = final[-1]
		result.append(dhee)
for yep in result:
	print(yep)


T = int(input())
for _ in range(T):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	q = list(range(n + x, 0, -1))
	for k in q:
		r = 0
		r1 = []
		for j in range(1, k + 1):
			if j not in a:
				r += 1
				r1 += [j]
		if r <= x:
			v = k
			break
	print(v)


for _ in range(int(input())):
	(n, k) = [int(s) for s in input().split()]
	arr = [int(s) for s in input().split()]
	freq = [False] * 250
	for i in arr:
		freq[i] = True
	for i in range(1, 251):
		if k == 0:
			break
		if not freq[i]:
			freq[i] = True
			k -= 1
	flag = False
	for i in range(1, 251):
		if not freq[i]:
			print(i - 1)
			flag = True
			break


a = int(input())
for i in range(a):
	(n, x) = map(int, input().split())
	z = list(map(int, input().split()))
	ans = [0 for i in range(100000)]
	for i in range(len(z)):
		ans[z[i] - 1] = 1
	temp = [0 for i in range(100000)]
	count = 1
	if ans[0] == 1:
		temp[0] = 0
	else:
		temp[0] = 1
		count += 1
	for i in range(1, len(temp)):
		if ans[i] == 0:
			temp[i] = count
			count = count + 1
		else:
			temp[i] = temp[i - 1]
	for i in range(len(temp)):
		if temp[i] == x:
			save = i
	print(save + 1)


import sys

def solve(inp, counter):
	inp = list(set(inp))
	inp.sort()
	save = 0
	track = 0
	while counter != 0 or track < len(inp):
		if track >= len(inp):
			save += counter
			break
		if inp[track] == save + 1:
			save += 1
			track += 1
		elif track < len(inp) and counter == 0:
			if inp[track] == inp[track - 1] + 1:
				save += 1
				track += 1
				continue
			else:
				break
		else:
			counter -= 1
			save += 1
	return save

def main():
	queries = []
	for line in sys.stdin.readlines():
		queries.append(line)
	for i in range(len(queries)):
		queries[i] = queries[i].rstrip()
	for i in range(1, len(queries), 2):
		temp = queries[i + 1].split(' ')
		inp = [int(x) for x in temp]
		temp = queries[i].split(' ')
		counter = int(temp[1])
		sol = solve(inp, counter)
		print(sol)
main()


def readIntArray():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, x) = readIntArray()
	a = readIntArray()
	st = set()
	for val in a:
		st.add(val)
	ans = 0
	for i in range(1, 300):
		if i not in st:
			if x == 0:
				break
			else:
				x -= 1
				ans += 1
		else:
			ans += 1
	print(ans)


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()

def iin():
	return int(input())

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

def main():
	T = iin()
	while T:
		T -= 1
		(n, x) = lin()
		a = set(lin())
		ch = 0
		while 1:
			if ch + 1 in a:
				pass
			else:
				if x == 0:
					break
				x -= 1
			ch += 1
		print(ch)
main()


def f(n, x, a):
	d = {i: 0 for i in a}
	c = 0
	for i in range(1, max(a) + 1):
		if i not in d:
			if x != 0:
				x -= 1
			else:
				return c
		c += 1
	if x > 0:
		c += x
	return c

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = [int(i) for i in input().split()]
		a = [int(i) for i in input().split()]
		print(f(n, x, a))
main()


t = int(input())
for tc in range(t):
	s1 = input().split()
	(n, x) = (int(s1[0]), int(s1[1]))
	s = input().split()
	num = []
	for i in s:
		k = int(i)
		if k not in num:
			num.append(k)
	i = 1
	ma = 1
	f1 = 0
	while 1:
		if x > 0:
			if i not in num:
				ma = i
				x -= 1
			else:
				ma = i
		else:
			while 1:
				if i not in num:
					f1 = 1
					break
				else:
					ma = i
				i += 1
		i += 1
		if f1 == 1:
			break
	print(ma)


from sys import stdin, stdout
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, stdin.readline().split()))
	for j in range(1, 202):
		if j not in l:
			if x == 0:
				print(j - 1)
				break
			x -= 1


import sys
input = sys.stdin.read()
data = list(map(int, input.split()))
T = int(data[0])
it = 1
while T > 0:
	a = data[it]
	x = data[it + 1]
	array = data[it + 2:it + 2 + a]
	count = 1
	check = 1
	while x:
		if not check in array:
			count += 1
			x -= 1
		check += 1
	for i in range(a):
		if check in array:
			check += 1
		else:
			break
	print(check - 1)
	it += 2 + a
	T -= 1


t = int(input())
r = []
for aaaaaa in range(t):
	(n, x) = [int(aaa) for aaa in input().split()]
	b = [int(aaaa) for aaaa in input().split()]
	a = []
	for z in b:
		if z not in a:
			a.append(z)
	a.sort()
	v = -1
	vmax = -1
	le = len(a)
	for i in range(le):
		k = a[i]
		e = k - i - 1
		if x >= e:
			v = k + x - e
		else:
			break
		if v > vmax:
			vmax = v
	if vmax == -1:
		vmax = x
	r.append(vmax)
for j in r:
	print(j)


M = 0

def update_M(j, s):
	global M
	if j == M + 1:
		M = j
		if j in s:
			s.remove(j)
		z = 1
		while True:
			if j + z in s:
				M += 1
				s.remove(j + z)
				z += 1
			else:
				break
	elif j in s:
		return
	elif j > M + 1:
		s.add(j)
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split(' ')))
	l = list(map(int, input().split(' ')))
	M = 0
	s = set()
	for j in l:
		update_M(j, s)
	for k in range(x):
		update_M(M + 1, s)
	print(M)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	c = [0] * (max(a) + 1)
	for i in a:
		c[i] = 1
	count = 0
	for i in range(1, len(c)):
		if c[i] == 0:
			c[i] = 1
			count += 1
		if count == x:
			break
	ok = True
	for j in range(1, len(c)):
		if c[j] == 0:
			print(j - 1)
			ok = False
			break
	if ok == True:
		print(len(c) + x - 1 - count)


a = int(input())
for _ in range(a):
	(x, y) = map(int, input().split())
	b = list(map(int, input().split()))
	b = list(set(b))
	b.sort()
	z = 0
	for i in b:
		if i == z + 1:
			z += 1
		elif i != z + 1 and y > 0:
			if abs(i - z - 1) <= y:
				y -= abs(i - z - 1)
				z = i
			elif abs(i - z - 1) > y:
				z = y + z
				y = 0
		elif i != z + 1 and y == 0:
			break
	if y > 0:
		print(z + y)
	else:
		print(z)


def main():
	T = int(input())
	for _ in range(T):
		(N, X) = map(int, input().split())
		A = set(list(map(int, input().split())))
		count = 0
		start = 1
		maxx = 1
		while count <= X:
			if start not in A:
				count += 1
			if count == X:
				maxx = max(maxx, start)
			start += 1
		print(maxx)
main()


T = int(input())
for _ in range(T):
	(N, X) = [int(x) for x in input().split()]
	vals = [int(x) for x in input().split()]
	vals = set(vals)
	V = 0
	while True:
		if V + 1 in vals:
			V += 1
		elif X > 0:
			X -= 1
			V += 1
		else:
			break
	print(V)


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	b = []
	i = 1
	while x != 0:
		if i in a:
			i += 1
		else:
			b.append(i)
			i += 1
			x -= 1
	c = a + b
	d = max(c)
	e = 0
	for i in range(1, d + 1):
		if i in c:
			e = i
		else:
			break
	print(e)


for _ in range(int(input())):
	(m, n) = input().split()
	(m, n) = (int(m), int(n))
	ls = sorted([int(x) for x in input().split()])
	res = 0
	i = 0
	while n >= 0 and i < m:
		if ls[i] > res + 1:
			if ls[i] - res - 1 > n:
				break
			else:
				n = n - (ls[i] - res - 1)
				res = ls[i]
		else:
			res = ls[i]
		i += 1
	res = res + n if n > 0 else res
	print(res)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l = sorted(set(l))
	ans = 0
	for i in range(1000):
		if i + 1 not in l:
			x -= 1
			if x < 0:
				print(ans)
				break
		ans += 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	lack = 0
	prev = 0
	ans = 0
	for i in range(n):
		lack = max(0, arr[i] - prev - 1)
		if lack > x:
			break
		x -= lack
		ans = arr[i]
		prev = ans
	print(ans + x)


def rankcollection(x, k):
	y = [0] * 100
	for i in range(len(x)):
		y[x[i] - 1] = 1
	s = 0
	i = 0
	while s <= k:
		if i < len(y):
			if y[i] == 0:
				s += 1
		else:
			s += 1
		i += 1
	return i - 1
cases = int(input())
for _ in range(cases):
	(l, k) = list(map(int, input().split()))
	x = list(map(int, input().split()))
	print(rankcollection(x, k))


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a_s = set(a)
	i = 1
	s = 0
	dup_x = x
	while i <= n + dup_x:
		if i in a_s:
			s += 1
		else:
			if x <= 0:
				break
			x -= 1
			s += 1
		i += 1
	print(s)


import sys
for _ in range(int(sys.stdin.readline())):
	(n, x) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	a = sorted(list(set(a)))
	b = [[a[i] - i - 1, i] for i in range(len(a)) if a[i] - i - 1 <= x]
	if b == []:
		print(x)
		continue
	b.sort()
	print(x + b[-1][1] + 1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	b = [0] * 222
	for i in map(int, input().split()):
		b[i] = 1
	ans = 0
	for i in range(1, 222):
		if b[i]:
			ans += 1
		elif x:
			x -= 1
			ans += 1
		else:
			break
	print(ans)


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, x) = [int(x) for x in inp().split()]
	a = [int(x) for x in inp().split()]
	a = set(a)
	got = 0
	while x > 0:
		i = got
		while True:
			if i + 1 not in a:
				a.add(i + 1)
				got = i + 1
				x -= 1
				break
			i += 1
	a = list(a)
	a.sort()
	i = 0
	while True:
		if i + 1 not in a:
			print(i)
			break
		i += 1


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = set(map(int, input().split()))
	l = list(l)
	l.sort()
	ll = [0 for i in range(300)]
	for i in l:
		ll[i] += 1
	i = 1
	while x > 0 or ll[i] == 1:
		if ll[i] == 0:
			x -= 1
			i += 1
		else:
			i += 1
	print(i - 1)


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().strip().split()]
	a = [int(x) for x in input().strip().split()]
	a = set(a)
	j = 1
	k = 0
	while k <= x:
		if j in a:
			j += 1
		else:
			k += 1
			j += 1
	print(j - 2)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	plc = [0] * 1000
	for aa in a:
		plc[aa] = 1
	for i in range(1, 1000):
		if plc[i] == 0 and x > 0:
			x -= 1
		elif plc[i] == 0:
			v = i - 1
			break
	print(v)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	array = list(map(int, input().split()))
	array = set(array)
	for i in range(1, 1000000000):
		if i not in array:
			array.add(i)
			x -= 1
		if x == 0:
			break
	array = sorted(list(array))
	c = 1
	for i in range(1, len(array)):
		if array[i] - array[i - 1] == 1:
			c += 1
		else:
			break
	print(c)


from sys import stdin, stdout
t = int(stdin.readline())
for case in range(t):
	(n, x) = map(int, stdin.readline().split())
	ary = list(map(int, stdin.readline().split()))
	taken = [False] * 201
	ans = 0
	for i in range(n):
		taken[ary[i]] = True
		count = 0
		for j in range(1, 201):
			if not taken[j]:
				count += 1
				if count > x:
					break
		if count > x:
			j = j - 1
		ans = max(ans, j)
	stdout.write('{}\n'.format(ans))


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(set(map(int, input().split())))
	n = len(a)
	b = a[0] - 1
	ans = min(a[0], x + (1 if a[0] - x == 1 else 0))
	for i in range(1, n):
		b += a[i] - a[i - 1] - 1
		if b > x:
			b -= a[i] - a[i - 1] - 1
			ans = a[i - 1] + (x - b)
			b = x + 1
			break
	if b <= x:
		ans = a[-1] + (x - b)
	print(ans)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	li = list(map(int, input().split()))
	ans = 0
	for i in range(1, 1000):
		if i in li:
			ans += 1
		elif x > 0:
			x -= 1
			ans += 1
		else:
			break
	print(ans)


I = lambda : map(int, input().split())
for t in range(int(input())):
	l = [0] * 101
	(n, x) = I()
	a = [*I()]
	a.sort()
	for v in a:
		l[v] = 1
	for i in range(1, 101):
		if l[i] == 0 and x:
			r = i
			x -= 1
		else:
			if l[i] == 0:
				r = i - 1
				break
			r = i
	if x:
		print(x + 100)
	else:
		print(r)


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split(' '))
	st = list(map(int, input().split(' ')))
	i = 1
	while x > 0:
		if i not in st:
			x -= 1
		else:
			st.remove(i)
		if x == 0:
			while i + 1 in st:
				i += 1
		else:
			i += 1
	print(i)


def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve():
	pass
t = read_int()
for case in range(t):
	(n, x) = read_ints()
	a = read_ints()
	pos = set(a)
	v = 1
	while x > 0:
		if v in pos:
			v += 1
		else:
			x -= 1
			if x > 0:
				v += 1
	while True:
		if v + 1 in pos:
			v += 1
		else:
			break
	print(v)


T = int(input())
for test_no in range(T):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = 0
	while True:
		if ans + 1 in l:
			ans += 1
		else:
			if m == 0:
				break
			ans += 1
			m -= 1
	print(ans)


for _ in range(0, int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	freq = {}
	for i in l:
		freq[i] = 1
	freq = {k: v for (k, v) in sorted(freq.items(), key=lambda item: item[0])}
	keys = list(freq.keys())
	l.sort(reverse=True)
	for i in l:
		if keys.index(i) + x + 1 >= i:
			print(keys.index(i) + x + 1)
			break
	else:
		print(x)


cycles = int(input())

def find_v(x, places):
	places = set(places)
	v = 0
	i = 1
	while True:
		if i in places:
			v = i
		elif x > 0:
			v = i
			x -= 1
		else:
			break
		i += 1
	return v
results = []
for cycle in range(cycles):
	(n, x) = map(int, input().split())
	places = map(int, input().split())
	results.append(find_v(x, places))
for r in results:
	print(r)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, X, A):
	setA = set(A)
	mx = max(A)
	numMissing = 0
	for i in range(1, mx + 1):
		if i not in A:
			if numMissing >= X:
				return i - 1
			numMissing += 1
	return mx + (X - numMissing)
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, X) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, X, A)
	print(ans)


test_cases = int(input(''))
for i in range(test_cases):
	line1 = [int(x) for x in str(input('')).split(' ')]
	placements = [int(x) for x in str(input('')).split(' ')]
	n_total_rounds = line1[0]
	x_rounds_more = line1[1]
	_max = max(placements)
	all_range = list(range(1, _max + 1000))
	for i in placements:
		if i in all_range:
			all_range.remove(i)
	get = all_range[:x_rounds_more]
	for i in get:
		placements.append(i)
	placements.sort()
	prev_i = 0
	for i in placements:
		if prev_i - i < -1:
			break
		prev_i = i
	print(prev_i)


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

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

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv(N, X, A):
	B = [False] * 1000
	for a in A:
		B[a - 1] = True
	f = 0
	for (i, b) in enumerate(B):
		if X > 0 and (not b):
			X -= 1
		elif X == 0 and (not b):
			return i - f

def main():
	T = read_int()
	for _ in range(T):
		(N, X) = read_int_n()
		A = read_int_n()
		print(slv(N, X, A))
main()


n = int(input())
while n:
	a = [int(x) for x in input().split()]
	x = a[1]
	b = list(set([int(x) for x in input().split()]))
	i = 1
	while x > 0:
		if i not in b:
			b.append(i)
			i += 1
			x -= 1
		else:
			i += 1
			pass
	i = 1
	ans = 0
	while i <= max(b):
		if i in b:
			ans += 1
		else:
			break
		i += 1
	print(ans)
	n -= 1


cases = int(input())
while cases:
	cases -= 1
	(a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = 0
	for i in range(1, 1000):
		if i in arr:
			ans += 1
			continue
		elif b > 0:
			ans += 1
			b -= 1
		else:
			break
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(set(a))
	a.sort()
	value = 0
	if len(a) == 1:
		if x >= a[0]:
			print(x + 1)
		elif a[0] - x == 1:
			print(a[0])
		else:
			print(x)
	else:
		for i in range(len(a)):
			if i == 0 and a[i] == 1:
				value += 1
			elif i == 0 and a[i] != 1:
				if x - a[i] >= -1:
					value = a[i]
					x -= a[i] - 1
				else:
					value = x
					break
			elif a[i] - a[i - 1] == 1:
				value = a[i]
			elif a[i] - a[i - 1] - 1 <= x:
				value = a[i]
				x -= a[i] - a[i - 1] - 1
			elif a[i] - a[i - 1] - 1 > x:
				value += x
				x = 0
				break
		if x > 0:
			value += x
		print(value)


numtests = int(input())
for _ in range(numtests):
	(n, x) = [int(t) for t in input().split()]
	l = [int(t) for t in input().split()]
	nextneeded = 1
	while x > 0 or nextneeded in l:
		if nextneeded not in l:
			x -= 1
		nextneeded += 1
	print(nextneeded - 1)


I = lambda : int(input())
Is = lambda : map(int, input().split())
Li = lambda : list(map(int, input().split()))

def solve():
	(n, x) = Is()
	a = Li()
	b = set(a)
	a.sort()
	cur = 0
	for i in range(1, 2000):
		if i not in b:
			if cur < x:
				cur += 1
				b.add(i)
			if cur == x:
				while i in b:
					i += 1
				while i not in b:
					i -= 1
				print(i)
				return
	return
t = I()
while t:
	solve()
	t -= 1


t = int(input())
for i in range(t):
	v = 0
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()][:n]
	a.sort()
	for j in range(max(a) + x):
		if j + 1 in a:
			v += 1
		elif x == 0:
			break
		else:
			v += 1
			x -= 1
	print(v)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	i = 1
	while k > 0:
		if i not in a:
			k = k - 1
			a.append(i)
			i = i + 1
		else:
			i = i + 1
	a.sort()
	c = 0
	for z in range(1, max(a) + 1):
		if z not in a:
			break
		else:
			c = z
	print(c)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	arr2 = [0] * 200
	for j in arr:
		arr2[j - 1] = 1
	count = 0
	for j in range(200):
		if arr2[j] == 0:
			count += 1
		if count == x:
			bi = j
			break
	for j in range(bi + 1, 200):
		if arr2[j] == 1:
			bi += 1
		else:
			break
	print(bi + 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	cnt = 0
	ans = 1
	while cnt <= x:
		if ans in a:
			pass
		else:
			cnt += 1
		ans += 1
	print(ans - 2)


t = int(input())
for i in range(t):
	lst1 = list(map(int, input().split(' ')))
	lst2 = list(map(int, input().split(' ')))
	n = lst1[0]
	x = lst1[1]
	rank = 1
	v = 0
	for i in range(x):
		while True:
			if rank not in lst2:
				v = rank
				rank += 1
				break
			else:
				v = rank
				rank += 1
	for j in range(n):
		if rank in lst2:
			v = rank
			rank += 1
		else:
			break
	print(v)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * 300
	for j in range(n):
		b[a[j]] = 1
	for j in range(1, 300):
		if b[j] == 0:
			x = x - 1
			if x == -1:
				print(j - 1)
				break


t = int(input())
li = []
for _ in range(t):
	res = 1
	count = 1
	(n, x) = map(int, input().split())
	li.extend(map(int, input().split()))
	li.sort()
	_set = set(li)
	new_li = list(_set)
	for j in range(1, n + x + 1):
		if new_li.count(j) == 0 and count <= x:
			new_li.append(j)
			count += 1
	new_li.sort()
	for k in new_li:
		if k == res:
			res += 1
			if k == new_li[-1]:
				print(res - 1)
		else:
			print(res - 1)
			break
	li.clear()
	new_li.clear()
	_set.clear()


import sys
input = lambda : sys.stdin.readline().rstrip()
print = sys.stdout.write
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = [0] * 202
	d[0] = 1
	for i in c:
		d[i] = 1
	start = 1
	while b:
		if d[start] == 0:
			d[start] = 1
			start += 1
			b -= 1
		else:
			start += 1
	print('{}\n'.format(d.index(0) - 1))


t = int(input())
for l in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	cnt = [0] * 10000
	for i in range(n):
		cnt[a[i] - 1] = 1
	cur = 0
	res = -1
	for i in range(10000):
		cur += cnt[i] == 1
		if i + 1 <= cur + x:
			res = cur + x
	print(res)


numcases = input()
numcases = int(numcases)

def count_holes():
	max_place = 0
	missing_numbers = 0
	number_missing = False
	for i in range(num_contests):
		if placings[i] > max_place:
			max_place = placings[i]
	for i in range(max_place):
		if i == 0:
			continue
		number_missing = isMissing(i)
		if number_missing == True:
			missing_numbers = missing_numbers + 1
		if missing_numbers > new_contests:
			return i - 1
	return new_contests + max_place - missing_numbers

def isMissing(numtest):
	for j in range(num_contests):
		if numtest == placings[j]:
			return False
	return True
for i in range(numcases):
	(num_contests, new_contests) = input().split(' ')
	num_contests = int(num_contests)
	new_contests = int(new_contests)
	placings = input().split(' ')
	for i in range(num_contests):
		placings[i] = int(placings[i])
	print(count_holes())


tc = int(input().strip())
for t in range(tc):
	(n, x) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	mn = min(arr)
	cnt = [0] * 1000
	cnt[mn] = mn - 1
	for i in range(mn - 1, 0, -1):
		cnt[i] = i
	for i in range(mn + 1, 1000):
		if i in arr:
			cnt[i] = cnt[i - 1]
		else:
			cnt[i] = cnt[i - 1] + 1
	for i in range(len(cnt) - 1, 0, -1):
		if cnt[i] == x:
			break
	print(i)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

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

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
t = INT()
while t != 0:
	(n, x) = MAP()
	a = LIST()
	uniq = list(set(a))
	L = max(uniq)
	for i in range(1, 1000):
		if x == 0:
			break
		if i not in uniq:
			uniq.append(i)
			x -= 1
	uniq.sort()
	flag = 0
	for (i, el) in enumerate(uniq):
		if i + 1 != el:
			flag = 1
			break
	if flag == 1:
		print(i)
	else:
		print(i + 1)
	t -= 1


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	c = list(sorted(set(map(int, input().split()))))
	k = 0
	while len(c):
		if c[0] == k + 1:
			k = c[0]
			c.pop(0)
		elif b:
			z = c[0] - k - 1
			if z <= b:
				k = c[0]
				b -= z
				c.pop(0)
			else:
				k = k + b
				b = 0
				c.pop(0)
		else:
			break
	print(k + b)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = [int(i) for i in input().split()]
	i = 0
	k = []
	while x != 0:
		i += 1
		if i not in l:
			x = x - 1
			l.append(i)
	s = set(l)
	l = list(s)
	l.sort()
	i = 1
	for e in l:
		if e != i:
			print(i - 1)
			break
		elif e == l[-1]:
			print(e)
		i += 1


q = int(input())
for _ in range(q):
	(n, x) = map(int, input().split())
	a = sorted({0} | set(map(int, input().split())))
	m = 0
	for i in range(len(a) - 1):
		if a[i + 1] - a[i] - 1 <= x:
			x -= a[i + 1] - a[i] - 1
			m = a[i + 1]
		else:
			break
	print(m + x)


t = int(input())
for cf in range(t):
	first = [int(i) for i in str(input()).split()]
	n = first[0]
	x = first[1]
	a = sorted(set([int(i) for i in str(input()).split()]))
	i = 0
	while x > 0:
		i += 1
		if i not in a:
			x -= 1
	i += 1
	while i in a:
		i += 1
	print(i - 1)


from sys import stdin, stdout
for t in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	a = [0] * 1001
	for v in map(int, stdin.readline().split()):
		a[v] = 1
	i = p = 1
	while p <= k:
		if a[i] == 0:
			a[i] = 1
			ans = i
			p += 1
		i += 1
	while a[ans] == 1:
		ans += 1
	stdout.write(str(ans - 1) + '\n')


def funcrank():
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	i = 1
	a.insert(0, 0)
	a.insert(n + 1, 200)
	while i < n + 1 and k >= 0:
		x = max(0, a[i] - a[i - 1] - 1)
		if k >= x:
			k -= x
		else:
			break
		i += 1
	print(a[i - 1] + k)
for c in range(int(input())):
	funcrank()


from sys import stdin, stdout

def f(a, n, x):
	ans = 0
	c = 1
	m = max(a)
	while x:
		if c not in a:
			x -= 1
		ans = c
		c += 1
	ans += 1
	while ans in a:
		ans += 1
	print(ans - 1)
t = int(input())
for i in range(t):
	(n, x) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	f(a, n, x)


t = int(input())
while t > 0:
	ip = input()
	(n, x) = list(map(int, ip.strip().split()))
	a = list(map(int, input().strip().split()))
	contestsWon = [0] * 500
	for contestRating in a:
		if contestsWon[contestRating - 1] == 0:
			contestsWon[contestRating - 1] = 1
	index = 0
	while x > 0:
		if contestsWon[index] == 0:
			contestsWon[index] = 1
			x -= 1
		index += 1
	v = 0
	for (idx, contest) in enumerate(contestsWon):
		if contest == 0:
			v = idx
			break
	print(v)
	t -= 1


c = int(input())
for i in range(0, c):
	if i == 0:
		(li0, x0) = map(int, input().split())
		lis0 = set(input().split())
		flag0 = 0
		num = 0
		a = 1
		while num <= x0:
			for ch in lis0:
				if a == int(ch):
					flag0 = flag0 + 1
					num = num - 1
			num = num + 1
			a = a + 1
	elif i == 1:
		(li1, x1) = map(int, input().split())
		lis1 = set(input().split())
		flag1 = 0
		num = 0
		a = 1
		while num <= x1:
			for ch in lis1:
				if a == int(ch):
					flag1 = flag1 + 1
					num = num - 1
			num = num + 1
			a = a + 1
	elif i == 2:
		(li2, x2) = map(int, input().split())
		lis2 = set(input().split())
		flag2 = 0
		num = 0
		a = 1
		while num <= x2:
			for ch in lis2:
				if a == int(ch):
					flag2 = flag2 + 1
					num = num - 1
			num = num + 1
			a = a + 1
	elif i == 3:
		(li3, x3) = map(int, input().split())
		lis3 = set(input().split())
		flag3 = 0
		num = 0
		a = 1
		while num <= x3:
			for ch in lis3:
				if a == int(ch):
					flag3 = flag3 + 1
					num = num - 1
			num = num + 1
			a = a + 1
	elif i == 4:
		(li4, x4) = map(int, input().split())
		lis4 = set(input().split())
		flag4 = 0
		num = 0
		a = 1
		while num <= x4:
			for ch in lis4:
				if a == int(ch):
					flag4 = flag4 + 1
					num = num - 1
			num = num + 1
			a = a + 1
for i in range(0, c):
	if i == 0:
		print(flag0 + x0)
	elif i == 1:
		print(flag1 + x1)
	elif i == 2:
		print(flag2 + x2)
	elif i == 3:
		print(flag3 + x3)
	elif i == 4:
		print(flag4 + x4)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(a)
	a = [0] * 1000
	i = 1
	while i < 1000:
		if i in b:
			a[i] = 1
		elif x > 0:
			x -= 1
			a[i] = 1
		elif x == 0 and i not in b:
			break
		i += 1
	print(sum(a))


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, x) = list(map(int, stdin.readline().rstrip().split(' ')))
	a = sorted(set(map(int, stdin.readline().rstrip().split(' '))))
	answer = 0
	idx = 0
	while x >= 0:
		if a[min(idx, len(a) - 1)] != answer + 1:
			x -= 1
		else:
			idx += 1
		answer += 1
	print(answer - 1)


trials = int(input())
answers = []

def func(l, x):
	l = list(dict.fromkeys(l))
	for (index, i) in enumerate(l):
		l[index] = int(i)
	positions = []
	for i in range(1, max(l) + x + 1):
		positions.append(i)
	for (index, i) in enumerate(positions):
		if i not in l:
			positions[index] = None
	v = None
	for (index, i) in enumerate(positions):
		if i != None:
			continue
		if x > 0:
			x -= 1
			if index == 0:
				positions[0] = 1
			else:
				positions[index] = positions[index - 1] + 1
			v = positions[index]
			continue
		if x == 0:
			v = positions[index - 1]
			break
	return v
while trials != 0:
	trials -= 1
	x = int(input().split()[1])
	l = input().split()
	answers.append(func(l, x))
for i in answers:
	print(i)


test = int(input())
while test:
	(n, x) = map(int, input().split())
	places = [int(i) for i in input().split()]
	listx = []
	i = 1
	while x:
		if i not in places:
			listx.append(i)
			x -= 1
		i += 1
	places.extend(listx)
	j = 1
	while j:
		if j in places:
			j += 1
		else:
			j = j - 1
			break
	print(j)
	test -= 1


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	cx = x
	place = 0
	for j in range(len(a) + x + 1):
		place = j + 1
		if not place in a:
			cx -= 1
		if cx == -1:
			break
	print(place + cx)


import sys
input = lambda : sys.stdin.readline().rstrip()

def zap():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 1
	while x != 0:
		if c not in a:
			x -= 1
		if x != 0:
			c += 1
	while c + 1 in a:
		c += 1
	print(c)

def main():
	for i in range(int(input())):
		zap()
main()


T = int(input())

def solve(n, x, a):
	sorted_a = sorted(list(set(a)))
	cons = []
	cons.append([sorted_a[0]])
	for (a_i, a_j) in zip(sorted_a, sorted_a[1:]):
		if a_i == a_j - 1:
			cons[-1].append(a_j)
		else:
			cons.append([a_j])
	while x > 0:
		if cons[0][0] != 1:
			if cons[0][0] == 2:
				cons[0] = [1] + cons[0]
			else:
				cons = [[1]] + cons
		elif len(cons) == 1:
			cons[0].append(cons[0][-1] + 1)
		elif cons[0][-1] == cons[1][0] - 2:
			cons[0] = cons[0] + [cons[0][-1] + 1] + cons[1]
			del cons[1]
		else:
			cons[0].append(cons[0][-1] + 1)
		x -= 1
	return len(cons[0])
for _ in range(T):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	print(solve(n, x, a))


def fxn(ar, y):
	j = 1
	missing = 0
	while missing <= y:
		if j not in ar:
			missing += 1
		else:
			pass
		j += 1
	return j - 2
t = int(input())
for i in range(t):
	(a, b) = input().split(' ')
	n = int(a)
	x = int(b)
	array = list(map(int, input().split(' ')))
	val = fxn(array, x)
	print(val)


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(list(set(a)))
	last = 0
	for i in a:
		dx = x - (i - last - 1)
		if dx < 0:
			break
		last = i
		x = dx
	print(last + x)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


for __ in range(int(input())):
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort()
	a = [0] * 400
	for i in ar:
		a[i] = 1
	for i in range(1, len(a)):
		if a[i] == 0:
			if m == 0 and a[i] == 0:
				ans = i - 1
				break
			else:
				m -= 1
	print(ans)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr = list(set(arr))
	ind = 1
	while True:
		if ind in arr:
			ind += 1
		elif x == 0:
			break
		else:
			x -= 1
			ind += 1
	print(ind - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = sorted(set(map(int, input().split())))
	add = 0
	for i in range(len(a)):
		if add + x + 1 >= a[i]:
			add += 1
		else:
			break
	print(add + x)


a = int(input())
for j in range(0, a):
	(a, x) = map(int, input().split())
	ab = set(map(int, input().split()))
	arr = list(ab)
	arr.sort()
	i = 1
	count = 0
	while x > 0:
		if i not in arr:
			arr.insert(i - 1, i)
			x = x - 1
		i = i + 1
	for i in range(1, len(arr) + 1):
		if i in arr:
			count = i
		else:
			break
	print(count)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	places = [False for _ in range(300)]
	for ai in a:
		places[ai] = True
	mx = None
	for ai in range(1, 300):
		if not places[ai]:
			if x == 0:
				break
			x -= 1
		mx = ai
	print(mx)


def find(n, m, li):
	v = 1
	li = set(li)
	while m != 0:
		if v not in li:
			m -= 1
		if m == 0:
			break
		v += 1
	while v + 1 in li:
		v += 1
	return v
for i in range(int(input())):
	(n, x) = map(int, input().split())
	li = map(int, input().split())
	print(find(n, x, li))


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().strip().split())
	ls = list(map(int, input().strip().split()))
	temp = [0] * 100
	for val in ls:
		temp[val - 1] = 1
	i = 0
	while x >= 0 and i < 100:
		if temp[i] == 0:
			if x == 0:
				break
			else:
				x -= 1
		i += 1
	print(i + x)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
test_count = int(input())
for t in range(test_count):
	(n, x) = invr()
	A = inlt()
	i = 0
	v = 0
	while i <= x:
		if v + 1 in A:
			v += 1
		else:
			i += 1
			if i > x:
				break
			else:
				v += 1
	print(v)


from math import log2
cases = int(input())
v = [0 for _ in range(cases)]
for case in range(cases):
	(n, x) = list(map(int, input().split(' ')))
	ranks = list(map(int, input().split(' ')))
	current_max = max(ranks)
	for i in range(1, x + 1):
		for place in range(i, current_max + 1 + x):
			if place not in ranks:
				v[case] = place
				ranks += [place]
				break
	ranks = sorted(list(set(ranks)))
	for r in ranks:
		if r > v[case] and r - v[case] == 1:
			v[case] = r
for e in v:
	print(e)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	values = [False] * 201
	for value in a:
		values[value - 1] = True
	for i in range(201):
		if values[i] == True:
			continue
		values[i] = True
		x -= 1
		if x < 1:
			break
	for i in range(201):
		if values[i] == False:
			print(i)
			break


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(set(a))
	a.sort()
	l = []
	j = 1
	counter = 0
	for i in a:
		if i == j:
			l.append(j)
			j += 1
		else:
			while i != j and counter < x:
				l.append(j)
				j += 1
				counter += 1
			if i == j:
				l.append(j)
				j += 1
	print(l[-1] + x - counter)


import sys
from functools import lru_cache
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

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

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

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, k) = sp()
	arr = set(l())
	m = max(arr)
	temp = k
	for i in range(1, m + temp + 1):
		if i in arr:
			pass
		else:
			if k == 0:
				i -= 1
				break
			k -= 1
	print(i)


t = int(input())
cases = []
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	places = [0 for _ in range(101)]
	for i in a:
		places[i] = 1
	s = 0
	done = False
	for i in range(1, 101):
		p = places[i]
		if not p:
			if s == x:
				print(i - 1)
				done = True
				break
			else:
				s += 1
	if not done:
		print(100 + (x - s))


for _ in range(int(input())):
	X = list(map(int, input().split()))
	Places = list(map(int, input().split()))
	Check = [False] * 10 ** 4
	for i in Places:
		Check[i] = True
	index = 1
	while X[1] > 0:
		if Check[index] == False:
			Check[index] = True
			X[1] -= 1
		index += 1
	print(Check[1:].index(False))


from collections import *
from bisect import *
from math import ceil, factorial, gcd
from heapq import *
t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(set(a))
	a.sort()
	r = 1
	for i in range(x):
		while r in a:
			r += 1
		r += 1
	while r in a:
		r += 1
	print(r - 1)


t = input('')
t = int(t)
i = 0
j = 0
k = 1
l = 1
a = list()
while i < t:
	(n, x) = input('').split()
	n = int(n)
	x = int(x)
	a = input('').split()
	while j < x:
		if str(k) not in a:
			a.append(str(k))
			j = j + 1
			k = k = 1
		elif str(k) in a:
			k = k + 1
	while l > 0:
		if str(l) in a:
			l = l + 1
			continue
		else:
			print(l - 1)
			l = 0
	j = 0
	l = 1
	k = 1
	i = i + 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = 0
	k = 0
	for i in range(1, n + x + 1):
		if i not in l:
			ans += 1
			if ans == x:
				break
	for j in range(i + 1, n + x + 1):
		if j in l:
			k += 1
		else:
			break
	print(i + k)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	ranking = [False] * (n + x + 1)
	for k in range(1, n + x + 1):
		if k not in arr and x > 0:
			arr.append(k)
			x -= 1
	for i in range(0, len(ranking)):
		if i + 1 in arr:
			ranking[i] = True
	flag = 0
	for p in range(len(ranking)):
		if ranking[p] == False:
			v = p
			flag = 1
			break
	if flag == 1:
		print(v)
	else:
		print(n + x)
	t -= 1


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split(' '))
	a = list(map(int, input().split()))
	d = {}
	d = defaultdict(lambda : 0, d)
	for i in a:
		d[i] = 1
	arr = []
	i = 1
	k = x
	while k > 0:
		if d[i] != 1:
			k -= 1
		i += 1
	while d[i] == 1:
		i += 1
	print(i - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	re = []
	j = 0
	i = 1
	while i < arr[-1]:
		if i == arr[j]:
			if arr[j] == arr[j + 1]:
				i -= 1
			j += 1
		else:
			re.append(i)
		i += 1
	if x >= len(re):
		print(arr[-1] + x - len(re))
	else:
		print(re[x] - 1)


t = int(input())
for rep in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	l = [0] * 101
	for i in range(n):
		l[a[i]] = 1
	temp = x
	pos = 0
	for j in range(1, 101):
		if l[j] == 0:
			if temp == 0:
				break
			else:
				temp -= 1
		pos += 1
	if temp != 0:
		pos += temp
	print(pos)


import sys
input = sys.stdin.readline
from math import *
t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().split())
	a = [int(p) for p in input().split()]
	b = [0 for i in range(1000)]
	for i in a:
		b[i] = 1
	c = 0
	for i in range(1, 1000):
		if b[i] == 0:
			c += 1
		if c > x:
			print(i - 1)
			break


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	_hash = [0] * 300
	for p in arr:
		_hash[p] = 1
	i = 1
	while x > 0:
		if _hash[i] == 0:
			_hash[i] = 1
			i += 1
			x -= 1
		else:
			i += 1
	i -= 1
	while _hash[i] == 1:
		i += 1
	print(i - 1)


import sys
from sys import stdin, stdout

def R():
	return map(int, stdin.readline().strip().split())
ans = []
for h in range(int(stdin.readline())):
	(n, x) = R()
	arr = list(R())
	dp = [0 for i in range(300)]
	for i in arr:
		dp[i] = 1
	i = 1
	while x:
		if dp[i] != 1:
			dp[i] = 1
			x -= 1
		i += 1
	for i in range(1, len(dp)):
		if dp[i] == 0:
			break
	i -= 1
	ans.append(str(i))
stdout.write('\n'.join(ans))


from sys import stdin, stdout
import math
t = int(stdin.readline())
for test in range(t):
	arr1 = [int(x) for x in stdin.readline().split()]
	arr2 = [int(x) for x in stdin.readline().split()]
	arr2.sort()
	n = arr1[0]
	x = arr1[1]
	arr = [0] * 201
	for i in arr2:
		arr[i - 1] = i
	i = 0
	while x > 0 or arr[i] != 0:
		if arr[i] == 0:
			arr[i] = i + 1
			x = x - 1
		i = i + 1
	stdout.write(str(i) + '\n')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split(' ')))
	a = [0 for i in range(max(l) + x + 1)]
	for i in l:
		a[i - 1] = 1
	i = 0
	while True:
		if a[i] == 0 and x > 0:
			x -= 1
			ans = i
			a[i] = 1
		if a[i] == 1:
			ans = i
		if x == 0 and a[i] == 0:
			print(ans + 1)
			break
		i += 1


itera = int(input())
for k in range(itera):
	(n, x) = list(map(int, input().split()))
	v = 0
	posicao = 1
	xcont = 0
	contests = list(map(int, input().split()))
	contests.sort()
	for i in range(len(contests)):
		if contests[i] == posicao:
			v += 1
			posicao += 1
		else:
			if contests[i] < posicao:
				continue
			if xcont == x:
				break
			while xcont < x and posicao != contests[i]:
				xcont += 1
				v += 1
				posicao += 1
			if posicao == contests[i]:
				v += 1
				posicao += 1
	if xcont < x:
		v += x - xcont
	print(v)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	nums = set(map(int, input().split()))
	nulls = [0] * 100
	for j in nums:
		nulls[j - 1] = 1
	for j in range(max(nums)):
		if nulls[j] == 0:
			if x != 0:
				x -= 1
			else:
				print(j)
				break
	else:
		print(max(nums) + x)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(set(a))
	f = True
	d = [0] * 210
	for i in range(len(a)):
		d[a[i]] = 1
	j = 1
	while f:
		if x == 0 and d[j] == 0:
			f = False
		elif x == 0 and d[j] == 1:
			j += 1
		elif d[j] == 1:
			j += 1
		else:
			j += 1
			x -= 1
	print(j - 1)


from math import *
from sys import *
t = int(stdin.readline())
for i in range(t):
	(n, x) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	k = 0
	ans = 0
	for i in range(n):
		d = a[i] - k - 1
		k += d + 1
		d = max(0, d)
		if x >= d:
			ans = k
			x -= d
		else:
			break
	if x > 0:
		ans += x
	print(ans)


test_case = int(input())
for _ in range(test_case):
	line0 = [int(_) for _ in input().strip().split()]
	(n, x) = (line0[0], line0[1])
	a = [int(_) for _ in input().strip().split()]
	arr = [0] * 250
	arr[0] = 1
	for i in a:
		arr[i] = 1
	ans = 1
	for (i, val) in enumerate(arr):
		if val == 1:
			ans = i
			continue
		elif x > 0:
			x -= 1
			ans = i
		else:
			break
	print(ans)
pass


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

def ii():
	return int(input())
testcases = int(input())
for t in range(testcases):
	(n, x) = li()
	pos = li()
	dic = dict()
	pos_max = max(pos)
	for i in range(n):
		try:
			dic[pos[i]] += 1
		except:
			dic[pos[i]] = 1
	c = 0
	i = 1
	while True:
		if i in dic.keys():
			c += 1
			i += 1
		elif x == 0:
			break
		else:
			x -= 1
			c += 1
			i += 1
	print(c)


t = int(input())
ans = 0
while t:
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	pos = [0] * 1000000
	pos[0] = 1
	for i in arr:
		pos[i] = 1
	for i in range(10 ** 6):
		if x == 0:
			break
		elif pos[i] == 0:
			pos[i] = 1
			x -= 1
	for i in range(10 ** 6):
		if pos[i] == 0:
			break
		ans = i
	print(ans)
	t -= 1


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = sorted(set(map(int, input().split())))
	c = 0
	i = 1
	while c <= x:
		if i not in a:
			c += 1
		i += 1
	print(i - 2)


def main():
	(n, x) = [int(i) for i in input().split()]
	q = sorted(list(set([int(i) for i in input().split()])))
	i = 0
	while x:
		i += 1
		if i not in q:
			x -= 1
	i += 1
	while i in q:
		i += 1
	print(i - 1)
for i in range(int(input())):
	main()


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	f = [0] * 203
	for i in a:
		f[i] += 1
	miss = []
	count = 0
	after = -1
	flag = False
	for i in range(1, n + x + 1):
		if f[i] == 0:
			if flag:
				after = i
				break
			miss.append(i)
			if len(miss) == x:
				flag = True
	if after >= 0:
		print(after - 1)
	else:
		print(n + x)


from sys import stdin
inp = stdin.readline
t = int(inp().strip())
for _ in range(t):
	(n, x) = [int(x) for x in inp().strip().split()]
	a = set([int(x) for x in inp().strip().split()])
	array = list()
	for i in range(1, 10 ** 6):
		if i not in a:
			if x == 0:
				print(i - 1)
				break
			x -= 1


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = [int(j) for j in input().split()]
	arr2 = [0] * 10000
	for y in arr:
		arr2[y] = 1
	ind = 1
	while x != 0:
		if arr2[ind] == 1:
			ind += 1
			continue
		x -= 1
		arr2[ind] = 1
	for i in range(1, 10000):
		if arr2[i] == 0:
			print(i - 1)
			break


t = int(input())
for i in range(t):
	s1 = input()
	s2 = s1.split(' ')
	n = int(s2[0])
	x = int(s2[1])
	a = input().split(' ')
	list = [0 for j in range(205)]
	for j in range(n):
		list[int(a[j])] = 1
	j = 1
	while x != 0:
		if list[j] == 0:
			x = x - 1
			list[j] = 1
		j = j + 1
	while list[j] != 0:
		j = j + 1
	j = j - 1
	print(j)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	v = 1
	while True:
		if v in A:
			v += 1
		elif x > 0:
			v += 1
			x -= 1
		else:
			break
	if v in A:
		print(v)
	else:
		print(v - 1)


t = int(input())
for q in range(t):
	(r, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	i = 1
	ans = 0
	while x >= 0:
		ans = i
		if i not in arr:
			x -= 1
		i += 1
	print(ans - 1)


import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda : int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda : list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda : float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda : list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda : stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda : stdin.readline().split()
from collections import defaultdict
t = ni()
for _ in range(t):
	(n, x) = na()
	a = na()
	ans = 0
	ac = [False] * 300
	for i in range(n):
		ac[a[i]] = True
	for i in range(n + x, 0, -1):
		cnt = 0
		for j in range(1, i + 1):
			if not ac[j]:
				cnt += 1
		if cnt <= x:
			ans = i
			break
	print(ans)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = sorted(set(map(int, input().split())))
	if min(l) != 1:
		l.insert(0, 1)
		x = x - 1
	if x > 0:
		j = 1
		while x > 0:
			if len(l) == j:
				l.insert(j, l[j - 1] + 1)
				x -= 1
			if l[j] - l[j - 1] != 1:
				l.insert(j, l[j - 1] + 1)
				x -= 1
			j += 1
	c = 0
	for j in range(1, len(l)):
		if l[j] - l[j - 1] != 1:
			print(l[j - 1])
			break
		c += 1
	if c == len(l) - 1:
		print(l[c])


from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from fractions import Fraction
from decimal import Decimal
import math
mod = pow(10, 9) + 7

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

def lit():
	return list(sp())

def fun(x):
	return sum((int(i) for i in str(x)))

def find(n):
	if n == 3:
		return 3
	while 1:
		flag = 0
		for i in range(2, int(sqrt(n)) + 1):
			if n % i == 0:
				n += 1
				break
			if i == int(sqrt(n)):
				flag = 1
				break
		if flag:
			break
	return n
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	i = 0
	while i < x + 1:
		i += 1
		if i in l:
			x += 1
	while x + 1 in l:
		x += 1
	print(x)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	temp = [0 for i in range(210)]
	for i in range(n):
		temp[a[i]] += 1
	for i in range(1, 210):
		if temp[i] == 0:
			x -= 1
		if x == 0:
			break
	res = i
	for j in range(i + 1, 210):
		if temp[j] == 0:
			break
		else:
			res += 1
	print(res)


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	for i in range(x):
		y = 1
		while y in a:
			y += 1
		a.append(y)
	e = 1
	while e in a:
		e += 1
	print(e - 1)


t = int(input())
while t != 0:
	(n, x) = map(int, input().split())
	list1 = list(map(int, input().split()))
	ans = x
	list1 = list(set(list1))
	for i in range(len(list1)):
		if list1[i] <= ans:
			ans += 1
	for i in range(len(list1)):
		if list1[i] == ans + 1:
			ans += 1
	print(ans)
	t -= 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	achieve = [False for i in range(201)]
	for i in range(1, n + x + 1):
		achieve[i] = False
	arr = list(map(int, input().split()))
	for i in arr:
		achieve[i] = True
	for k in range(n + x, -1, -1):
		v = 0
		for i in range(1, k + 1):
			if achieve[i] == False:
				v += 1
		if v <= x:
			print(k)
			break


t = int(input())
for i in range(t):
	first_line = input().split()
	n = int(first_line[0])
	x = int(first_line[1])
	contests = input().split()
	for j in range(n):
		contests[j] = int(contests[j])
	rank = 0
	while x >= 0:
		rank += 1
		if rank in contests:
			continue
		x -= 1
	print(rank - 1)


t = int(input())
while t:
	t -= 1
	(n, x) = [int(y) for y in input().split(' ')]
	l = [int(y) for y in input().split(' ')]
	for i in range(1, 1000):
		if i not in l:
			x -= 1
		if x == 0:
			break
	for a in range(i + 1, 1000):
		if a not in l:
			print(a - 1)
			break


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	rank = [0] * 400
	for i in a:
		rank[i - 1] = 1
	i = 0
	while i < 400 and x > 0:
		if rank[i] == 0:
			rank[i] = 1
			x -= 1
		i += 1
	print(rank.index(0))


t = int(input())
for i in range(t):
	(n, x) = input().strip().split(' ')
	(n, x) = [int(n), int(x)]
	a = list(map(int, input().strip().split(' ')))
	xx = [0 for _ in range(300)]
	for i in a:
		xx[i] = 1
	xx = xx[1:]
	for i in range(300):
		if xx[i] == 0:
			x -= 1
		if x == -1:
			pp = i
			print(pp)
			break


m = int(input())
for i in range(m):
	(n, x) = [int(i) for i in input().split()]
	a = set([int(b) for b in input().split()])
	m = 0
	for j in range(1, 101):
		if x > 0:
			if j not in a:
				a.add(j)
				x -= 1
		else:
			m = j
			break
	if x >= 0 and len(a) == 100:
		print(100 + x)
		continue
	for l in range(m, 100):
		if l not in a:
			print(l - 1)
			break


testcases = int(input())
for testcase in range(testcases):
	arr = input()
	arr = arr.split()
	n = int(arr[0])
	x = int(arr[1])
	dicts = {}
	newarr = str(input())
	newarr = newarr.split()
	for i in newarr:
		newi = int(i)
		dicts[newi] = 1
	ans = 0
	for i in range(1, 1000):
		if i in dicts:
			ans += 1
			continue
		if x == 0:
			break
		x -= 1
		ans += 1
	print(ans)


testCases = int(input())
for i1 in range(testCases):
	(length, x) = list(map(int, input().split()))
	rankings = list(map(int, input().split()))
	ranking_set = set(rankings)
	discrete_ranking = list(ranking_set)
	discrete_ranking.sort()
	rank_exists = [False] * (discrete_ranking[len(discrete_ranking) - 1] + x)
	for i2 in discrete_ranking:
		rank_exists[i2 - 1] = True
	numbers_inserted = 0
	index = 0
	while True:
		if numbers_inserted == x:
			break
		if not rank_exists[index]:
			rank_exists[index] = True
			numbers_inserted += 1
		if numbers_inserted == x:
			break
		index += 1
	index = 0
	while index < len(rank_exists) and rank_exists[index]:
		index += 1
	print(index)


for u in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	d = [0] * 206
	for i in range(n):
		if d[l[i]] == 0:
			d[l[i]] = 1
	for i in range(1, 204):
		if d[i] == 0:
			d[i] = 1
			x = x - 1
		if x == 0:
			break
	i = 1
	c = 0
	while d[i] != 0:
		c = c + 1
		i = i + 1
	print(c)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	b = sorted(list(set(list(map(int, input().split())))))
	k = dict()
	for j in range(len(b)):
		k[b[j]] = 1
	for j in range(1, 204):
		if x > 0:
			if j in k.keys() and x > 0:
				pass
			else:
				x += -1
				if x == 0:
					p = j
		elif x == 0:
			if j in k.keys():
				p = j
			else:
				break
	print(p)


def contests(lista, x):
	i = 1
	while x > 0:
		if i in lista:
			x = x
		else:
			x = x - 1
		i += 1
	while i in lista:
		i += 1
	return i - 1
t = int(input())
for i in range(t):
	(n, x) = input().split()
	x = int(x)
	lista = input().split()
	for k in range(int(n)):
		lista[k] = int(lista[k])
	print(contests(lista, x))


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	dict = {}
	s = list(map(int, input().split()))
	for i in range(n):
		dict[s[i]] = 1
	count = 0
	while True:
		if dict.get(count + 1) is None and x <= 0:
			break
		if dict.get(count + 1) is None:
			x -= 1
		count += 1
	print(count)


t = int(input())
for test in range(t):
	(n, have) = input().split()
	(n, have) = (int(n), int(have))
	arr = list(map(int, input().split()))
	arr = list(set(arr))
	arr.sort()
	n = len(arr)
	mx = 0
	for i in range(n):
		if arr[i] > mx:
			if have >= arr[i] - mx - 1:
				have -= arr[i] - mx - 1
				mx = arr[i]
			else:
				mx = mx + have
				have = 0
				break
	if have > 0:
		mx = mx + have
	print(mx)