#include <bits/stdc++.h>
int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int t; cin >> t;
	while (t--) {
		int n, k; cin >> n >> k;
		set<int> S;
		unordered_map<int, int> haved;
		for (int i = 0; i < n; ++i) {
			int x; cin >> x;
			S.insert(x); haved[x] = true;
		}
		if (k == 0) {
			cout << n << '\n';
			continue;
		}
		if (*S.rbegin() == n - 1) {
			cout << n + k << '\n';
		} else {
			int i = 0;
			for (auto it = S.begin(); it != S.end(); ++it, ++i) {
				if (*it != i) break;
			}
			if (haved[(i + *S.rbegin() + 1) / 2]) {
				cout << n << '\n';
			} else {
				cout << n + 1 << '\n';
			}
		}
	}
}