#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define nl "\n"

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t--){
		int n, k;
		cin >> n >> k;
		unordered_set <int> uset;
		int maxi = -1;
		for (int i = 0; i < n; i++){
			int temp;
			cin >> temp;
			uset.insert(temp);
			maxi = max(maxi, temp);
		}
		// cout << maxi << nl;
		int i = 0;
		while (true){
			if (uset.find(i) == uset.end())
				break;
			i++;
		}
		// cout << i << nl;
		int x = ceil(((double)maxi+i)/2);
		// cout << x << nl;
		bool find = uset.find(x) == uset.end();
		// cout << find << nl;
		if (x <= maxi && k > 0){
			if (find == false)
				cout << n;
			else
				cout << n+1;
		}
		else{
			cout << n+k;
		}
		cout << nl;

	}

}