#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

bool present(ll ele, ll* arr, ll n) {
	for (int i = 0; i < n; i++) {
		if (arr[i] == ele) {
			return (true);
		}
	}
	return (false);
}

int main() {
	int t;
	cin >> t;
	while (t--) {
		ll n, k;
		cin >> n >> k;
		ll* arr = new ll[n];
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
		}
		if (k == 0) {
			cout << n << endl;
			continue;
		}
		sort(arr, arr + n);
		ll MAX = arr[n - 1];
		ll MEX = 0;
		for (int i = 0; i < n; i++) {
			if (arr[i] != MEX) {
				break;
			}
			MEX++;
		}
		if (MEX > MAX) {
			cout << n + k << endl;
		}
		else {
			ll newE = ceil((MEX + MAX) / 2.0);
			if (present(newE, arr, n)) {
				cout << n << endl;
			}
			else {
				cout << n + 1 << endl;
			}
		}
		delete[] arr;
	}
	return (0);
}